Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 321 by [email protected]: PID file should be created before daemonizing
http://code.google.com/p/memcached/issues/detail?id=321

Some monitoring programs rely on the presence of a PID file to determine whether a daemon successfully started. memcached is creating the PID file after daemonizing, resulting in a short period where it looks as though the daemon failed to start. This is easy to demonstrate. Try the following several times. You will always see "cat: foo.pid: No such file or directory" displayed before the actual PID.

rm -f foo.pid; killall -q -w memcached; memcached -d -P `pwd`/foo.pid; cat foo.pid; sleep 1; cat foo.pid

Ideally, most of the initialization should be done before daemonizing so that when the fork happens, memcached is definitely going to stay up and is ready to take requests, but I can appreciate that this isn't always straightforward. However, simply creating the PID file before forking should not be a problem.

I recently had to make the same change for a Ruby project. It's a different language but exactly the same principle applies.

https://github.com/adhearsion/adhearsion/commit/7ed93239e281c25bc5a45a89b1f2da4584dbc778#lib/adhearsion/foundation/custom_daemonizer.rb

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--

--- You received this message because you are subscribed to the Google Groups "memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to