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: Unicorn preload_app and upstart
Date: Thu, 19 May 2011 18:35:34 +0000	[thread overview]
Message-ID: <20110519183534.GA6075@dcvr.yhbt.net> (raw)
In-Reply-To: <C9FAE2E1.1F37%rob.greenwood@melbourne.co.uk>

Rob Greenwood <Rob.Greenwood@melbourne.co.uk> wrote:
> Hi,
> 
> I was wondering if anyone has managed to get the preload_app and SIGUSR2
> combination working well with upstart?
> 
> My issue currently is that when I perform a SIGUSR2 against the master,
> check everything's working and close off the old master, upstart then
> attempts to restart it because the original PID/binary are no longer
> running.

I guess upstart is similar to daemontools in this respect?

I posted a potentially working script to wrap unicorn and preserve
the same pid with daemon tools in this thread:

http://thread.gmane.org/gmane.comp.lang.ruby.unicorn.general/917
http://mid.gmane.org/20110425183458.GA5826%40dcvr.yhbt.net

> What is the correct way of handling this? In my opinion, should unicorn
> not always be using the same master process and just spawning additional
> children/cycling them? Else the above functionality will never work with
> upstart, which will be replacing init.

USR2 needs to be able to load a new Ruby executable and the only way is
to replace the master.  And for "preload_app true" to work, Unicorn
itself has to manage processes.


If you teach upstart/daemontools to bind listeners, you can have them
export a comma-separated list of listener file descriptors in the
UNICORN_FD environment (e.g. UNICORN_FD=3,4) and use QUIT + restart in
upstart/daemontools and avoid using USR2 entirely.

Unicorn itself still has to be given the listen directives in its own
config file otherwise it'll close them (because it assumes the user
no longer wants them on upgrade) and also to change socket options
if there are any.

You'll still get transparent restarts because the listeners will be
owned by daemontools/upstart and the queued listeners will be
held there.


Unicorn doesn't need to be used with upstart/daemontools, the master
process should be just as robust as them.  The only possible issue is
during HUP/USR2 where a bad upgrade has an (unlikely) chance of killing
the master, but if you're issuing HUP/USR2, you're paying attention to
the machine anyways.

If you want auto-startup, consider having a startup task in the @reboot
line in a crontab.  You can even put it in a regular user's crontab to
avoid needing to switch users.


Everything about the Unicorn process model with upstart/daemontools
applies to nginx upgrades, too.

-- 
Eric Wong
_______________________________________________
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:[~2011-05-19 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-19 14:08 Unicorn preload_app and upstart Rob Greenwood
2011-05-19 18:35 ` Eric Wong [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-05-19 13:39 Rob Greenwood

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=20110519183534.GA6075@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).