pid file deleted briefly when doing hot restart

Petteri Räty betelgeuse at
Tue Nov 27 01:49:01 UTC 2012

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:

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 *


More information about the mongrel-unicorn mailing list