3 | | `deluged.service`: |
| 3 | Firstly ensure Deluge daemon `deluged` and Web UI `deluge-web` are [wiki:Installing/Linux installed]. |
| 4 | |
| 5 | == User Management == |
| 6 | |
| 7 | For security it is best to run a service with a specific user and group. You can create one using the following command: |
| 8 | |
| 9 | {{{ |
| 10 | sudo adduser --system --gecos "Deluge Service" --disabled-password --group --home /var/lib/deluge deluge |
| 11 | }}} |
| 12 | |
| 13 | * This creates a new system user and group named `deluge` with no login access and home directory: `/var/lib/deluge` |
| 14 | |
| 15 | Add to the `deluge` group any users you wish to be able to easily manage or access files downloaded through Deluge, for example: |
| 16 | |
| 17 | {{{ |
| 18 | sudo adduser <username> deluge |
| 19 | }}} |
| 20 | |
| 21 | |
| 22 | == Migration from init.d or upstart script == |
| 23 | Get rid of any old init files named deluge in `/etc/init.d/` like this: |
| 24 | {{{ |
| 25 | sudo /etc/init.d/deluge-daemon stop |
| 26 | sudo rm /etc/init.d/deluge-daemon |
| 27 | sudo update-rc.d deluge-daemon remove |
| 28 | }}} |
| 29 | |
| 30 | Remove old upstart scripts like this: |
| 31 | {{{ |
| 32 | sudo stop deluged |
| 33 | sudo stop deluge-web |
| 34 | sudo rm /etc/init/deluge-web.conf |
| 35 | sudo rm /etc/init/deluged.conf |
| 36 | }}} |
| 37 | |
| 38 | == Deluge Daemon (deluged) Service == |
| 39 | Create the file `/etc/systemd/system/deluged.service`: |
| 76 | |
| 77 | Now start the service and verify it is running: |
| 78 | {{{ |
| 79 | systemctl start deluge-web |
| 80 | systemctl status deluge-web |
| 81 | }}} |
| 82 | |
| 83 | Note: Both these service scripts should be updated so that deluge-web starts on deluged service and both respawn, the same as [wiki:UserGuide/InitScript/ upstart scripts]. |
| 84 | |
| 85 | == Enable the service on boot == |
| 86 | |
| 87 | Enable the services to start up on boot: |
| 88 | {{{ |
| 89 | systemctl enable deluged |
| 90 | systemctl enable deluge-web |
| 91 | }}} |
| 92 | |
| 93 | == Logging == |
| 94 | Create a structure for Deluge to log to and give the user that Deluge is running as (in this case `deluge`) full access to that directory: |
| 95 | {{{ |
| 96 | sudo mkdir -p /var/log/deluge |
| 97 | sudo chown -R deluge:deluge /var/log/deluge |
| 98 | sudo chmod -R 750 /var/log/deluge |
| 99 | }}} |
| 100 | * Note: The above commands affect the log directory and all files within it, combined with the umask specified in the upstart jobs these affect the permissions new logs are created with. |
| 101 | * 750 grants full access to the deluge user, only recurse tree and read access to members of the deluge group and prevents access from all other accounts. [http://en.wikipedia.org/wiki/Chmod#Octal_numbers Chmod] |
| 102 | Edit the service files like so: |
| 103 | {{{ |
| 104 | ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning |
| 105 | }}} |
| 106 | {{{ |
| 107 | ExecStart=/usr/bin/deluge-web -l /var/log/deluge/web.log -L warning |
| 108 | }}} |
| 109 | * Refer to the [wiki:Faq#EnableDelugeLogging FAQ] for possible log-levels. |
| 110 | |
| 111 | Restart the daemon: |
| 112 | {{{ |
| 113 | sudo restart deluged |
| 114 | }}} |
| 115 | |
| 116 | Create `/etc/logrotate.d/deluge` with the following code to rotate the logs: |
| 117 | {{{ |
| 118 | /var/log/deluge/*.log { |
| 119 | rotate 4 |
| 120 | weekly |
| 121 | missingok |
| 122 | notifempty |
| 123 | compress |
| 124 | delaycompress |
| 125 | sharedscripts |
| 126 | postrotate |
| 127 | initctl restart deluged >/dev/null 2>&1 || true |
| 128 | initctl restart deluge-web >/dev/null 2>&1 || true |
| 129 | endscript |
| 130 | } |
| 131 | }}} |