Changes between Version 1 and Version 2 of UserGuide/Service/systemd


Ignore:
Timestamp:
08/21/2014 12:00:46 PM (9 years ago)
Author:
Cas
Comment:

Add details on setting up systemd

Legend:

Unmodified
Added
Removed
Modified
  • UserGuide/Service/systemd

    v1 v2  
    11= systemd Scripts = 
    22 
    3 `deluged.service`: 
     3Firstly ensure Deluge daemon `deluged` and Web UI `deluge-web` are [wiki:Installing/Linux installed]. 
     4 
     5== User Management == 
     6 
     7For security it is best to run a service with a specific user and group. You can create one using the following command: 
     8 
     9{{{ 
     10sudo 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 
     15Add to the `deluge` group any users you wish to be able to easily manage or access files downloaded through Deluge, for example: 
     16 
     17{{{ 
     18sudo adduser <username> deluge 
     19}}} 
     20 
     21 
     22== Migration from init.d or upstart script == 
     23Get rid of any old init files named deluge in `/etc/init.d/` like this: 
     24{{{ 
     25sudo /etc/init.d/deluge-daemon stop 
     26sudo rm /etc/init.d/deluge-daemon 
     27sudo update-rc.d deluge-daemon remove 
     28}}} 
     29 
     30Remove old upstart scripts like this: 
     31{{{ 
     32sudo stop deluged 
     33sudo stop deluge-web 
     34sudo rm /etc/init/deluge-web.conf 
     35sudo rm /etc/init/deluged.conf 
     36}}} 
     37 
     38== Deluge Daemon (deluged) Service == 
     39Create the file `/etc/systemd/system/deluged.service`: 
    440{{{ 
    541[Unit] 
     
    1652}}} 
    1753 
     54Now start the service and verify it is running: 
     55{{{ 
     56systemctl start deluged 
     57systemctl status deluged 
     58}}} 
    1859 
    19 `deluge-web.service`: 
     60== Deluge Web UI (deluge-web) Service == 
     61 
     62Create the file `/etc/systemd/system/deluge-web.service`: 
    2063{{{ 
    2164[Unit] 
     
    3174WantedBy=multi-user.target 
    3275}}} 
     76 
     77Now start the service and verify it is running: 
     78{{{ 
     79systemctl start deluge-web 
     80systemctl status deluge-web 
     81}}} 
     82 
     83Note: 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 
     87Enable the services to start up on boot: 
     88{{{ 
     89systemctl enable deluged 
     90systemctl enable deluge-web 
     91}}} 
     92 
     93== Logging == 
     94Create 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{{{ 
     96sudo mkdir -p /var/log/deluge 
     97sudo chown -R deluge:deluge /var/log/deluge 
     98sudo 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] 
     102Edit the service files like so: 
     103{{{ 
     104ExecStart=/usr/bin/deluged -d -l /var/log/deluge/daemon.log -L warning 
     105}}} 
     106{{{ 
     107ExecStart=/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 
     111Restart the daemon: 
     112{{{ 
     113sudo restart deluged 
     114}}} 
     115 
     116Create `/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}}}