module documentation
Module with helper classes and functions for daemons
Class |
|
A way to notify the asyncore loop that something is going on. |
Class |
|
An improved asyncore udp socket. |
Class |
|
Base Ganeti Asyncore Dispacher |
Class |
|
Generic mainloop for daemons |
Function |
|
Shared main function for daemons. |
Class | _ |
Logic for Mainloop shutdown. |
Function | _ |
Try to format an error better. |
Function | _ |
Handler for SIGHUP. |
Function | _ |
Verifies the process uid matches the configured uid. |
def GenericMain(daemon_name, optionparser, check_fn, prepare_fn, exec_fn, multithreaded=False, console_logging=False, default_ssl_cert=None, default_ssl_key=None, warn_breach=False):
¶
Shared main function for daemons.
Parameters | |
daemon | daemon name |
optionparser:optparse.OptionParser | initialized optionparser with daemon-specific options (common -f -d options will be handled by this module) |
check | function that checks start conditions and exits if they're not met |
prepare | function that is run before forking, or None; it's result will be passed as the third parameter to exec_fn, or if None was passed in, we will just pass None to exec_fn |
exec | function that's executed with the daemon's pid file held, and runs the daemon itself. |
multithreaded:bool | Whether the daemon uses threads |
console | if True, the daemon will fall back to the system console if logging fails |
default | Default SSL certificate path |
default | Default SSL key path |
warn | issue a warning at daemon launch time, before daemonizing, about the possibility of breaking parameter privacy invariants through the otherwise helpful debug logging. |
Try to format an error better.
Since we're dealing with daemon startup errors, in many cases this will be due to socket error and such, so we try to format these cases better.
Parameters | |
err | an exception object |
Returns | |
string | the formatted error description |
Handler for SIGHUP.
Parameters | |
reopen | List of callback functions for reopening log files |
signum | Undocumented |
frame | Undocumented |
Verifies the process uid matches the configured uid.
This method verifies that a daemon is started as the user it is intended to be run
Parameters | |
daemon | The name of daemon to be started |
Returns | |
A tuple with the first item indicating success or not, the second item current uid and third with expected uid |