pid file deleted briefly when doing hot restart

Eric Wong normalperson at yhbt.net
Tue Nov 27 02:02:24 UTC 2012


Petteri Räty <betelgeuse at gentoo.org> wrote:
> On 27.11.2012 2.35, Eric Wong wrote:
> 
> >>
> >> nginx does not explicitly unlink the old pid file before it renames it
> >> out of the way so yes matching nginx in that regard changes the behavior
> >> exactly how I originally asked but you were against that. Maybe the
> >> point is moot though.
> > 
> > Ah, I thought you wanted the pid file to be replaced without
> > a window where the file is non-existent (or empty).
> > 
> 
> That would be ideal but I meant this thread to be explicitly about the
> unlink and resulting couple seconds window. Now that I have spend some
> thinking about the issue here's an approach using hard links that can be
> used to replace the pid without window of non-existance:

Yes, this is ideal, but unfortunately, the window of non-existence is
necessary for compatibility with some existing (nginx-based) scripts.

PID files are horrible :<

> betelgeuse at mac ~/inotify/test_files $ echo "old" > a
> betelgeuse at mac ~/inotify/test_files $ ln a a.oldbin
> betelgeuse at mac ~/inotify/test_files $ for file in *; do echo $file:
> $(stat -f %i $file); done
> a: 3730129
> a.oldbin: 3730129
> betelgeuse at mac ~/inotify/test_files $ echo "new" > b
> betelgeuse at mac ~/inotify/test_files $ mv b a
> betelgeuse at mac ~/inotify/test_files $ for file in *; do echo $file:
> $(stat -f %i $file); done
> a: 3730137
> a.oldbin: 3730129
> betelgeuse at mac ~/inotify/test_files $ cat *
> new
> old


More information about the mongrel-unicorn mailing list