From: "Iñaki Baz Castillo" <ibc@aliax.net>
To: unicorn list <mongrel-unicorn@rubyforge.org>
Subject: Re: [PATCH] initialize signal handlers before writing pid file
Date: Wed, 20 Jan 2010 09:45:33 +0100 [thread overview]
Message-ID: <201001200945.33438.ibc@aliax.net> (raw)
In-Reply-To: <20100120023826.GA25165@dcvr.yhbt.net>
El Miércoles, 20 de Enero de 2010, Eric Wong escribió:
> This prevents trigger-happy init scripts from reading the pid
> file (and thus sending signals) to a not-fully initialized
> master process to handle them.
>
> This does NOT fix anything if other processes are sending
> signals prematurely without relying on the presence of the pid
> file. It's not possible to prevent all cases of this in one
> process, even in a purely C application, so we won't bother
> trying.
>
> We continue to always defer signal handling to the main loop
> anyways, and signals sent to the master process will be
> deferred/ignored until Unicorn::HttpServer#join is run.
Hi Eric, I've already tested it. It works great :)
To check it I use the following init script "reload" action which hope could
be useful for others (it requires loading "/lib/lsb/init-functions"):
reload|force-reload|safe-reload)
# Return
# 0 if daemon has been reloaded
# 1 if daemon was not running
# 1 if daemon could not be reloaded
#
log_daemon_msg "Safe reloading $DESC"
oldpid=$(pidofproc -p $PIDFILE)
if [ "$oldpid" ] ; then
kill -s USR2 $oldpid
log_action_msg "signal USR2 sent to $NAME master process (pid $oldpid) to
fork a new master and workers processes"
log_action_msg "waiting for the new process to successfully start..."
printf "."
sleep 1
while [ "$(pidofproc -p $PIDFILE.oldbin)" ]; do
printf "."
sleep 1
done
echo
newpid=$(pidofproc -p $PIDFILE)
# If the PID has definitively changed than the new master is running.
if [ "$oldpid" != "$newpid" ] ; then
log_success_msg "server correctly reloaded, new master process has pid
$newpid"
log_end_msg 0
# If not, the new master process couldn't start due to the new
# configuration or code error.
else
log_failure_msg "error running a new master process, $NAME was not
reloaded (check error log)"
log_end_msg 1
fi
else
log_failure_msg "$NAME is not running"
log_end_msg 1
fi
;;
And I test the following loop to check it:
while [ 0 ] ; do /etc/init.d/myserver reload ; done
--
Iñaki Baz Castillo <ibc@aliax.net>
_______________________________________________
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
prev parent reply other threads:[~2010-01-20 8:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-17 1:44 Issue when sending USR2 too soon Iñaki Baz Castillo
2010-01-17 1:52 ` Iñaki Baz Castillo
2010-01-17 1:59 ` Iñaki Baz Castillo
2010-01-18 11:04 ` Eric Wong
2010-01-18 11:25 ` Iñaki Baz Castillo
2010-01-18 11:43 ` Eric Wong
2010-01-18 11:48 ` Iñaki Baz Castillo
2010-01-20 2:38 ` [PATCH] initialize signal handlers before writing pid file Eric Wong
2010-01-20 8:45 ` Iñaki Baz Castillo [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=201001200945.33438.ibc@aliax.net \
--to=ibc@aliax.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).