Python daemonisation with python-daemon
Ben Finney
ben+python at benfinney.id.au
Sat May 1 06:55:24 EDT 2010
Thomas Courbon <thcourbon at gmail.com> writes:
> I would like to turn my server script into a Linux/Unix daemon
> (launched at boot time by init, dunno if that matter) using the nice
> python-daemon package by Ben Finley et al
I resemble that name :-)
> This package comes with a class DaemonRunner that seems to fit almost
> exactly my need but I still have some interrogation.
Yes, that class is unlikely to grow much beyond a simple example of how
to use ‘DaemonContext’. You should feel free to take ‘DaemonRunner’
under the granted license and adapt it to be closer to what you want.
> The DaemonRunner class expects my class to have stdin_path,
> stdout_path, stderr_path attributes and after reading the code it
> seems they have to be valid paths. Is that ok for a Daemon to redirect
> those stream to /dev/null for example ? I would prefer to alter the
> DaemonRunner class to accept None as value since DaemonContext, the
> underlying class, seems to accept None for those parameters.
This is a godd idea, allowing a more minimal use of ‘DaemonRunner’. I'll
take this as a feature request for a future revision of the class.
> Also, the DaemonRunner use os.kill(pid, signal.SIGTERM) to stop the
> daemon. I wonder if with my signal handling I'll be able to terminate
> correctly the daemon (joining children, flushing buffers, closing
> connections...). If that's relevant, the connection I use is a
> Listener/Client connection from the standard multiprocessing module.
I'll be interested to know too :-)
> I'm quite neophyte in Unix daemon programming so please forgive me if
> my question are obvious.
Thank you for your feedback, and I hope the ‘python-daemon’ library
continues to meet your needs.
--
\ “In the long run, the utility of all non-Free software |
`\ approaches zero. All non-Free software is a dead end.” —Mark |
_o__) Pilgrim, 2006 |
Ben Finney
More information about the Python-list
mailing list