class plinth.daemon.Daemon(component_id, unit, strict_check=False, listen_ports=None, alias=None)[source]

Component to manage a background daemon or any systemd unit.

__init__(component_id, unit, strict_check=False, listen_ports=None, alias=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.


Check if the daemon is running and listening on expected ports.

See plinth.app.Component.diagnose().


Run operations to disable the daemon/unit.


Run operations to enable the daemon/unit.


Return if the daemon/unit is enabled.


Return whether the daemon/unit is running.