gitlab/unicorn.rb: Configure preload_app and pre-/post- forking actions
authorKirill Smelkov <kirr@nexedi.com>
Thu, 7 Jan 2016 17:47:54 +0000 (20:47 +0300)
committerKirill Smelkov <kirr@nexedi.com>
Sun, 17 Jan 2016 21:39:29 +0000 (00:39 +0300)
commitd599096aded4447b1b2b21af07d33a66abfff66a
tree99bf71d4f047c7d8a810254cc9fe667e4af87761
parent0aae33d92565dc85133bf0cb215ccff412ab8d0b
gitlab/unicorn.rb: Configure preload_app and pre-/post- forking actions

Unicorn is a forking server with the idea that master process preloads
heavy Ruby-on-Rails application, and then to handle new request a worker
process is forked with application already loaded in its memory (and
modification being tracked by OS via copy-on-write).

From this point of view the only reasonable value for preload_app is
always "true" and omnibus-gitlab does this:

    https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8eda0933/files/gitlab-cookbooks/gitlab/definitions/unicorn_service.rb#L65

Then unicorn documentation shows what code has to be there in pre-/post-
forking event:

    http://bogomips.org/unicorn.git/tree/examples/unicorn.conf.rb?id=3312aca8#n57

GitLab uses only part of it that "allows a new master process to
incrementally phase out the old master process with SIGTTOU to avoid a
thundering herd":

    https://gitlab.com/gitlab-org/omnibus-gitlab/blob/8eda0933/files/gitlab-cookbooks/gitlab/definitions/unicorn_service.rb#L69
    http://bogomips.org/unicorn.git/tree/examples/unicorn.conf.rb?id=3312aca8#n75

but strangely does not use code parts that are "highly recommended" or
"require" for "Rails + "preload_app true"" case.

For the reference I've added such codes, but kept them being commented
out.

/cc @kazuhiko, @jerome
software/gitlab/template/unicorn.rb.in