unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: Detecting unicorn / defining after_fork after master startup
Date: Sun, 22 Jul 2012 14:20:26 -0700	[thread overview]
Message-ID: <20120722212026.GA17948@dcvr.yhbt.net> (raw)
In-Reply-To: <CAJf_-UsSYXQGeArVoUXTOewnR8esfaoeu6rwnbD3Np+Vh6bFJQ@mail.gmail.com>

Matt Sanders <matt@modal.org> wrote:
> On Thu, Jul 19, 2012 at 6:13 PM, Eric Wong <normalperson@yhbt.net> wrote:
> > Matt Sanders <matt@modal.org> wrote:
> >> 2. Is there an established way for adding an after_fork hook after
> >> Unicorn has already started up?
> >
> > Nothing that I know of.
> >
> >> I'm aware of the ability to do this via the config file but I don't
> >> want my users to have to add something to their unicorn config file.
> >> Is there an equivalent to passenger's
> >> PhusionPassenger.on_event(:starting_worker_process) method?
> >
> > Lately, I've been favoring the following pattern instead:

(top-posting corrected)

> Thanks! I definitely agree in general with that pattern. In this case
> I'd ideally like some activity on the forked child before the next
> request cycle - that is, if the forked child doesn't serve any
> requests for a little bit, I'd still like my behavior to be
> initialized.

Yes, that sucks.  I'll often just throw some requests at the child
just to start something up if I need it, or initiate a separate daemon.

> Do you know of a way to get this behavior without a direct after fork hook?

No, unfortunately not.  I have considered petitioning for something
along the lines of pthread_atfork() in Ruby, but pthread_atfork() itself
also has unfortunate drawbacks (it makes fork() async-signal un-safe,
and thus _Fork() will be introduced in the next version of POSIX).
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

      reply	other threads:[~2012-07-22 21:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19 22:43 Detecting unicorn / defining after_fork after master startup Matt Sanders
2012-07-19 22:55 ` Ben Somers
2012-07-19 22:59   ` Matt Sanders
2012-07-19 23:13 ` Eric Wong
2012-07-21 19:42   ` Matt Sanders
2012-07-22 21:20     ` Eric Wong [this message]

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=20120722212026.GA17948@dcvr.yhbt.net \
    --to=normalperson@yhbt.net \
    --cc=mongrel-unicorn@rubyforge.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).