order of operations when daemonizing
Ethan Furman
ethan at stoneleaf.us
Tue May 20 16:58:04 UTC 2014
Greetings!
I just started using the daemon module, and I have a few questions:
1) Why are DaemonRunner and DaemonContext two different things? I would have
thought that part of being a "well-behaved daemon" included stopping and
restarting.
2) Why does DaemonContext lose privilege and detach before setup is complete?
This is causing me four problems:
a) I can't create a pid file in /var/run
b) I don't see any errors because it's already detached by the time this
happens
c) If I use the wrong pid class from daemon.pidfile (there are two:
PIDLockFile and TimeoutPIDLockFile) then the daemon just sits forever
waiting for the pid file to lock, but since it's already detached it
appears to have worked, yet nothing is happening from the daemon that
should be happening.
d) if the daemon is already running there is no notice of this, again
because the new instance has already detached and the "pidfile already
locked" exception disappears into the ether.
I suggest that the detach happen after all the prep work is complete, which solves most of the above issues.
I also suggest that daemon.pidfile import PIDLockFile as _PIDLockFile as it's not really there for the end user.
I'm happy to help with development, I just need to figure out bazaar. :)
--
~Ethan~
More information about the python-daemon-devel
mailing list