Daemon

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.

diagnose()[source]

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

See plinth.app.Component.diagnose().

disable()[source]

Run operations to disable the daemon/unit.

enable()[source]

Run operations to enable the daemon/unit.

is_enabled()[source]

Return if the daemon/unit is enabled.

is_running()[source]

Return whether the daemon/unit is running.

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.

__init__(component_id, unit)[source]

Initialize a new related daemon component.

‘component_id’ must be a unique string across all apps and components of a app. Conventionally starts with ‘related-daemon-‘.

‘unit’ must the name of systemd unit.