patroni.daemon module

Daemon processes abstraction module.

This module implements abstraction classes and functions for creating and managing daemon processes in Patroni. Currently it is only used for the main “Thread” of patroni and patroni_raft_controller commands.

class _patroni.daemon.AbstractPatroniDaemon(_config: Config) View on GitHub

Bases: ABC + A Patroni daemon process. + Note

When inheriting from link:#patroni.daemon.AbstractPatroniDaemon[`+AbstractPatroniDaemon+`] you are expected to define the methods link:#patroni.daemon.AbstractPatroniDaemon._run_cycle[`+_run_cycle()+`] to determine what it should do in each execution cycle, and link:#patroni.daemon.AbstractPatroniDaemon._shutdown[`+_shutdown()+`] to determine what it should do when shutting down.
+
Variables:;;
+
\\__init\\__(_config: link:patroni.config.html#patroni.config.Config[Config]_) →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L50-L61[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.\\__init\\__[];;
  Set up signal handlers, logging handler and configuration.
  +
  Parameters:::
    *config* – configuration options for this daemon.
+
_abc_impl_ = <_abc._abc_data object>_link:#patroni.daemon.AbstractPatroniDaemon._abc_impl[];;
+
_abstract \\__run_cycle() →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L124-L129[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon._run_cycle[];;
  Define what the daemon should do in each execution cycle.
  +
  Keep being called in the daemon’s main loop until the daemon is eventually terminated.
+
_abstract \\__shutdown() →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L145-L147[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon._shutdown[];;
  Define what the daemon should do when shutting down.
+
api_sigterm() →  https://docs.python.org/3/library/functions.html#bool[bool] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L70-L82[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.api_sigterm[];;
  Guarantee only a single SIGTERM is being processed.
  +
  Flag the daemon as “SIGTERM received” with a lock-based approach.
  +
  Returns:::
    `+True+` if the daemon was flagged as “SIGTERM received”.
+
_property _received_sigterm_:  https://docs.python.org/3/library/functions.html#bool[bool]_link:#patroni.daemon.AbstractPatroniDaemon.received_sigterm[];;
  If daemon was signaled with SIGTERM.
+
reload_config(_sighup:  https://docs.python.org/3/library/functions.html#bool[bool] = False_, _local:  https://docs.python.org/3/library/functions.html#bool[bool] |  https://docs.python.org/3/library/constants.html#None[None] = False_) →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L114-L122[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.reload_config[];;
  Reload configuration.
  +
  Parameters:::
+
run() →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L131-L143[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.run[];;
  Run the daemon process.
  +
  Start the logger thread and keep running execution cycles until a SIGTERM is eventually received. Also reload configuration uppon receiving SIGHUP.
+
setup_signal_handlers() →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L92-L106[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.setup_signal_handlers[];;
  Set up daemon signal handlers.
  +
  Set up SIGHUP and SIGTERM signal handlers.
  +
  Note
  SIGHUP is only handled in non-Windows environments.
+
shutdown() →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L149-L157[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.shutdown[];;
  Shut the daemon down when a SIGTERM is received.
  +
  Shut down the daemon process and the logger thread.
+
sighup_handler(_*_:  https://docs.python.org/3/library/typing.html#typing.Any[Any]_) →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L63-L68[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.sighup_handler[];;
  Handle SIGHUP signals.
  +
  Flag the daemon as “SIGHUP received”.
+
sigterm_handler(_*_:  https://docs.python.org/3/library/typing.html#typing.Any[Any]_) →  https://docs.python.org/3/library/constants.html#None[None] https://github.com/zalando/patroni/blob/9d231aeecdd69f4d06c75a702755fa70d8c2b5f6/patroni/daemon.py#L84-L90[View on GitHub]link:#patroni.daemon.AbstractPatroniDaemon.sigterm_handler[];;
  Handle SIGTERM signals.
  +
  Terminate the daemon process through link:#patroni.daemon.AbstractPatroniDaemon.api_sigterm[`+api_sigterm()+`].
patroni.daemon.abstract_main(cls: Type[AbstractPatroniDaemon], configfile: str) → None View on GitHub

Create the main entry point of a given daemon process. +

Parameters:
patroni.daemon.get_base_arg_parser() → ArgumentParser View on GitHub

Create a basic argument parser with the arguments used for both patroni and raft controller daemon. +

Returns:

‘argparse.ArgumentParser’ object


© Copyright 2015 Compose, Zalando SE. Revision 9d231aee.

Built with Sphinx using a theme provided by Read the Docs.

Read the Docs v: latest

+ Builds