Unicorn / Daemontools

Eric Wong normalperson at yhbt.net
Mon Apr 25 14:34:58 EDT 2011


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 Wong


More information about the mongrel-unicorn mailing list