Daemon#
- class plinth.daemon.Daemon(component_id: str, unit: str, strict_check: bool = False, listen_ports: list[tuple[int, str]] | None = None, alias: str | None = None)[source]#
Component to manage a background daemon or any systemd unit.
- __init__(component_id: str, unit: str, strict_check: bool = False, listen_ports: list[tuple[int, str]] | None = None, alias: str | None = None)[source]#
Initialize a new daemon component.
‘component_id’ must be a unique string across all apps and components of a app. Conventionally starts with ‘daemon-‘.
‘unit’ must the name of systemd unit that this component should manage.
‘listen_ports’ is a list of tuples. Each tuple contains the port number as integer followed by a string with one of the values ‘tcp4’, ‘tcp6’, ‘tcp’, ‘udp4’, ‘udp6’, ‘udp’ indicating the protocol that the daemon listens on. This information is used to run diagnostic tests.
‘alias’ is an alternate name for the same unit file. When a unit file is renamed, the new unit file usually contains an Alias= setting in [Install] section with value of old unit name. When the unit is enabled, a symlink with the name of the alias is created. All operations such as is-running and disable work with the alias along with the primary unit name. However, for the case of enabling the unit file or checking its enabled status, the alias does not work. To be able to provide management for multiple versions of the unit file with different names, specify an alias. Both the names are taken into consideration when enabling the unit file.
- diagnose() list[DiagnosticCheck][source]#
Check if the daemon is running and listening on expected ports.
- class plinth.daemon.RelatedDaemon(component_id, unit)[source]#
Component to hold information about additional systemd units handled.
Unlike a daemon described by the Daemon component which is enabled/disabled when the app is enabled/disabled, the daemon described by this component is unaffected by the app’s enabled/disabled status. The app only has an indirect interest in this daemon.
This component primarily holds information about such daemon and does nothing else. This information is used to check if the app is allowed to perform operations on the daemon.
Component to manage a daemon that is used by multiple apps.
Daemons such as a database server are a hard requirement for an app. However, there may be multiple apps using that server. This component ensures that server is enabled and running when app is enabled. It runs diagnostics on the daemon when app is diagnosed. The primary difference from the Daemon component is that when the app is disabled the daemon must only be disabled if there is no other app using this daemon.
Disable the daemon iff this is the last app using the daemon.
Do nothing. Enabled state is still determined by unit status.