systemd

Usage

The python-systemd package is required to run the pa-dlna systemd service unit.

pa-dlna runs as a systemd/User service unit (Pulseaudio and Pipewire run also as a user service unit). Only one Control Point (such as pa-dlna) may interact with a given DLNA device and pa-dlna enforces this rule by allowing only one pa-dlna process per Sound Server.

Systemd commands for pa-dlna

Purpose

Command

Enable pa-dlna and start it

systemctl --user enable --now pa-dlna

Disable pa-dlna and stop it

systemctl --user disable --now pa-dlna

Start pa-dlna

systemctl --user start pa-dlna

Stop pa-dlna

systemctl --user stop pa-dlna

Get the state of pa-dlna

systemctl --user status pa-dlna

Print the journal of pa-dlna

journalctl --user -u pa-dlna

The pa-dlna.service unit

The pa-dlna.service unit file is located in the systemd directory at the root of the pa-dlna git repository.

Its content is:

# When enabled, the pa-dlna service unit is started automatically after the
# pulseaudio or pipewire service unit is started. It will also stop when the
# pulseaudio or pipewire service unit stops. However it will stop when the
# pulseaudio or pipewire service unit is restarted but it will not start.
#
# Both pa-dlna and pulseaudio service units are of 'Type=notify'. This means
# that pa-dlna will only start after pulseaudio has notified systemd that it
# is ready and pa-dlna may connect successfully to libpulse.
#
# However the pipewire service unit is of 'Type=simple'. In that case and if
# pa-dlna fails to start with the error:
#       LibPulseStateError(('PA_CONTEXT_FAILED', 'Connection refused'))
# add a delay to the pa-dlna start up sequence with the directive:
#       ExecStartPre=/bin/sleep 1
#
# Any pa-dlna option may be added to the 'ExecStart' directive, for example to
# restrict the allowed NICs or IP addresses (recommended) or to change the
# log level.
# The '--systemd' option is required.
#
# The 'python-systemd' package is required.

[Unit]
Description=Pa-dlna Service
Documentation=https://pa-dlna.readthedocs.io/en/stable/

After=pipewire-session-manager.service pulseaudio.service

[Service]
Type=notify
ExecStart=/usr/bin/pa-dlna --systemd
Slice=session.slice

NoNewPrivileges=yes
UMask=0077

[Install]
WantedBy=pipewire-session-manager.service pulseaudio.service