How to create systemd services for LinuxThis guide walks you through setting up Deluge systemd services on Linux. Ensure Deluge daemon Create a service specific userFor security it is best to run a service with a specific user and group. You can create one using the following command: sudo adduser --system --gecos "Deluge Service" --disabled-password --group --home /var/lib/deluge deluge usermod -u 2114 deluge groupmod -g 2122 deluge chmod -R deluge:deluge /var/lib/deluge This creates a new system user and group named In addition you can add to the sudo adduser <username> deluge
Daemon (deluged) serviceCreate the file [Unit] Description=Deluge Bittorrent Client Daemon Documentation=man:deluged After=network-online.target [Service] Type=simple UMask=007 ExecStart=/usr/bin/deluged -d Restart=on-failure # Time to wait before forcefully stopped. TimeoutStopSec=300 [Install] WantedBy=multi-user.target User configurationTo run the service using the previously created user e.g. sudo mkdir /etc/systemd/system/deluged.service.d/
Then create a user file # Override service user [Service] User=deluge Group=deluge Start deluged serviceNow enable it to start up on boot, start the service and verify it is running: sudo systemctl enable /etc/systemd/system/deluged.service sudo systemctl start deluged sudo systemctl status deluged Umask for deluged downloaded filesThe
The service for Web UI (deluge-web) serviceCreate the file [Unit] Description=Deluge Bittorrent Client Web Interface Documentation=man:deluge-web After=network-online.target deluged.service Wants=deluged.service [Service] Type=simple UMask=027 ExecStart=/usr/bin/deluge-web -d Restart=on-failure [Install] WantedBy=multi-user.target User configurationTo run the service using the previously created user e.g. sudo mkdir /etc/systemd/system/deluge-web.service.d/ Then create a user file # Override service user [Service] User=deluge Group=deluge Service loggingCreate a log directory for Deluge and give the service user (e.g. sudo mkdir -p /var/log/deluge sudo chown -R deluge:deluge /var/log/deluge sudo chmod -R 750 /var/log/deluge The deluge log directory is now configured so that user Enable logging in the service files by editing the ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning ExecStart=/usr/bin/deluge-web -d -l /var/log/deluge/web.log -L warning See Restart the services: sudo systemctl daemon-reload sudo systemctl restart deluged sudo systemctl restart deluge-web Conditionally start deluged for mount pointsIf you have a USB disk drive or network drive that may not be immediately available on boot or disconnected at random then you may want the Ensure you have added the correct drive details to List the available drive mounts: sudo systemctl -t mount
Look for your mount point in the Modify the [Unit] Description=Deluge Bittorrent Client Daemon # Start after network and specified mounts are available. After=network-online.target xyz.mount Requires=xyz.mount # Stops deluged if mount points disconnect BindsTo=xyz.mount For multiple mount points add a space between additional entries. e.g.: After=network-online.target xyz.mount abc.mount def.mount Modify the [Install] WantedBy=multi-user.target xyz.mount Reference: systemd.unit https://deluge.readthedocs.io/en/latest/how-to/systemd-service.html |
Linux Links >