[Mongrel] Why not ignore stale PID files?

Hongli Lai hongli at plan99.net
Tue Jun 10 19:28:42 EDT 2008


Hongli Lai wrote:
> This works great, even on Windows. The only gotchas are:
> - flock() doesn't work over NFS. You'll have to use some kind of fcntl() 
> call to lock files over NFS, but I'm not sure whether Ruby provides an 
> API for that.
> - foo.global.lock is never deleted. You cannot safely delete it without 
> creating some kind of racing condition.

I forgot to mention that it is safe to delete foo.lock. So the shutdown 
part of the daemon code should look like this:

   lock(foo.global.lock)
   delete_file(foo.pid)
   unlock(foo.lock)
   delete_file(foo.lock)     # added this line
   unlock(foo.global.lock)


More information about the Mongrel-users mailing list