unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: "Bráulio Bhavamitra" <braulio@eita.org.br>
To: Eric Wong <e@80x24.org>
Cc: unicorn-public <unicorn-public@bogomips.org>
Subject: Re: Master hooks needed
Date: Fri, 3 Oct 2014 22:35:02 -0300	[thread overview]
Message-ID: <CAJri6_s+ofUH5CrPyeLFvoqQ3hCr9r1EY6NLnU-F2gUGTFFMNw@mail.gmail.com> (raw)
In-Reply-To: <20141004012210.GA8134@dcvr.yhbt.net>

I think the hook is needed because I took too much time to figure out
the problem and much more time to figure out the solution (this
master_run variable). Also, I don't think this master_run solution is
elegant.

cheers,
bráulio

On Fri, Oct 3, 2014 at 10:22 PM, Eric Wong <e@80x24.org> wrote:
> Bráulio Bhavamitra <braulio@eita.org.br> wrote:
>> The problem is actually worser, and the worker.nr == 0 can't be used.
>> I had to do something like this:
>>
>> master_run = true
>>
>> before_fork do |server, worker|
>>   if master_run
>>      #warm up server...
>>
>>      #kill old pid...
>>
>>      #disconnect active record
>>
>>      master_run = false
>>   end
>>
>>   # other stuff for each worker
>> end
>>
>> In the last example, using worker.nr == 0 would make the server crash
>> in case the worker 0 was killed/restarted.
>>
>> Also the AR's disconnect and *many other stuff* people put on
>> before_fork should only be run once the master was preloaded, not for
>> every worker.
>
> AR disconnect! is idempotent and has been since unicorn existed.
> I suspect most other things people run in before_fork are already
> idempotent, too.
>
>> So I still think at least a hook like master_preloaded(server) is necessary.
>
> Using the local 'master_run' variable in your before_fork already
> accomplishes everything you needed, right?
>
> I try to keep unicorn as lean as possible and not bloat it with
> redundant features.  The current hooks already fulfill the minimal
> requirements for supporting apps which do not behave properly under
> preload_app=true, so I am not convinced why a new hook is necessary.

  reply	other threads:[~2014-10-04  1:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03 11:34 Master hooks needed Bráulio Bhavamitra
2014-10-03 12:22 ` Eric Wong
2014-10-03 12:36   ` Valentin Mihov
2014-10-03 17:50     ` Eric Wong
2014-10-03 18:12       ` Valentin Mihov
2014-10-04  0:53   ` Bráulio Bhavamitra
2014-10-04  1:22     ` Eric Wong
2014-10-04  1:35       ` Bráulio Bhavamitra [this message]
2014-10-04  1:57         ` Eric Wong
2014-10-04  2:04           ` Bráulio Bhavamitra
2014-10-04  2:25             ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJri6_s+ofUH5CrPyeLFvoqQ3hCr9r1EY6NLnU-F2gUGTFFMNw@mail.gmail.com \
    --to=braulio@eita.org.br \
    --cc=e@80x24.org \
    --cc=unicorn-public@bogomips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).