pep3143daemon is a implementation of the PEP 3143, describing a well behaving Unix daemon, as documented in Stevens ‘Unix Network Programming’
freezer.lib.pep3143daemon.
DaemonContext
(chroot_directory=None, working_directory='/', umask=0, uid=None, gid=None, prevent_core=True, detach_process=None, files_preserve=None, pidfile=None, stdin=None, stdout=None, stderr=None, signal_map=None)¶Bases: object
Implementation of PEP 3143 DaemonContext class
This class should be instantiated only once in every program that has to become a Unix Daemon. Typically you should call its open method after you have done everything that may require root privileges. For example opening port <= 1024.
Each option can be passed as a keyword argument to the constructor, but can also be changed by assigning a new value to the corresponding attribute on the instance.
Altering attributes after open() is called, will have no effect. In future versions, trying to do so, will may raise a DaemonError.
Parameters: |
|
---|
close
()¶Dummy function
is_open
¶True when this instances open method was called
Returns: | bool |
---|
open
()¶Daemonize this process
Do everything that is needed to become a Unix daemon.
Returns: | None |
---|---|
Raise: | DaemonError |
terminate
(signal_number, stack_frame)¶Terminate this process
Simply terminate this process by raising SystemExit. This method is called if signal.SIGTERM was received.
Check carefully if this really is what you want!
Most likely it is not!
You should implement a function/method that is able to cleanly shutdown you daemon. Like gracefully terminating child processes, threads. or closing files.
You can create a custom handler by overriding this method, ot setting a custom handler via the signal_map. It is also possible to set the signal handlers directly via signal.signal().
Returns: | None |
---|---|
Raise: | SystemExit |
working_directory
¶The working_directory property
Returns: | str |
---|
freezer.lib.pep3143daemon.
DaemonError
¶Bases: Exception
Exception raised by DaemonContext
freezer.lib.pep3143daemon.
PidFile
(pidfile)¶Bases: object
PidFile implementation for PEP 3143 Daemon.
This Class can also be used with pythons ‘with’ statement.
Parameters: | pidfile (str) – filename to be used as pidfile, including path |
---|
acquire
()¶Acquire the pidfile.
Create the pidfile, lock it, write the pid into it and register the release with atexit.
Returns: | None |
---|---|
Raise: | SystemExit |
release
()¶Release the pidfile.
Close and delete the Pidfile.
Returns: | None |
---|
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.