Unicorn / Daemontools

Curtis j Schofield curtis.schofield at gmail.com
Mon Apr 25 15:03:57 EDT 2011


On Mon, Apr 25, 2011 at 11:34 AM, Eric Wong <normalperson at yhbt.net> wrote:
> Curtis j Schofield <curtis.schofield at gmail.com> wrote:
>> I tried to get Daemontools and Unicorn working together a while back -
>> there are issues on USR2 restart because of the pid
>> change - I'm hoping someone  in the community will have some
>> understanding of this issue
>
> I have no experience with daemontools directly, but I expect any
> solutions people found to make daemontools work with nginx USR2
> would also work for unicorn since they have the same process/signal
> model.
>
> Maybe a hacky way would be to have daemontools run this wrapper
> script instead of Unicorn:
>
> -------------------------------- 8< -------------------------
> #!/bin/sh
> set -e
>
> # this script is totally untested and written by someone who's never
> # used daemontools
>
> # start Unicorn in the background:
> bundle exec unicorn -D ...
>
> # forward signals received in this wrapper to the Unicorn process:
> for sig in HUP USR1 USR2 QUIT TERM QUIT
> do
>        trap 'kill -'$sig' $(cat $UNICORN_PID_FILE)' $sig
> done
>
> # loop forever while Unicorn has its pid file
> # a smarter, Linux-only version of this would use inotify instead
> while test -f $UNICORN_PID_FILE
> do
>        sleep 1
> done
>


 Eric! This is fascinating!


 If i run a wrapper with unicorn as a child process - i can detect the
absence of the wrapper - and
i can detect the absence of the pid file - but i cannot detect a hard
fail in the unicorn process unless i have some kind of pipe
open to the child and register that failure.

Is my understanding correct?

Daemontools is design to take a process that is running in the
foreground and monitor it - keep it alive - the breakdown in unicorn
is when a USR2 arrives at unicorn - and the pid switch occurs - daemon
tools believes it has lost the process.

I see this as a design flaw in all pid based monitoring solutions - in
my experiences.



> --
> Eric Wong
> _______________________________________________
> Unicorn mailing list - mongrel-unicorn at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-unicorn
> Do not quote signatures (like this one) or top post when replying
>



-- 
make haste slowly \
festina lente  \
-
mobile  +1_415_632_6001
curtis.schofield at gmail.com
http://robotarmyma.de


More information about the mongrel-unicorn mailing list