pid file deleted briefly when doing hot restart
normalperson at yhbt.net
Mon Nov 26 00:43:01 UTC 2012
Petteri Räty <betelgeuse at gentoo.org> wrote:
> What follows are all the write actions related to unicorn pid file when
> doing a hot restart. Seems like a bug to me that unicorn is deleting the
> pid file before writing the new file. Is there a reason for it? It seems
> to go against that rename that aims for an atomic replace that would
> always ensure the pid file is there.
Unfortunately, pid files are inherently racy. However, I
seem to recall a pid file not existing for a brief moment was needed
to allow some nginx-based scripts to work.
I think unicorn differs a bit from nginx here:
nginx uses rename() to clear the way for a new pid file. Like unicorn,
this still leaves a window where no pid file exists.
Also, nginx does not create a randomly named pid file before renaming
it, so there's a possibility another process can read an existing, but
zero-byte file. unicorn avoids this, if a pid file exists, it has a pid
More information about the mongrel-unicorn