| 1 | = Ubuntu Upstart Job = |
| 2 | |
| 3 | Based on the previous Ubuntu scripts [http://dev.deluge-torrent.org/wiki/UserGuide/InitScript/Ubuntu/ here]. |
| 4 | |
| 5 | === Notes === |
| 6 | * This seems to work for me. |
| 7 | * I can't remember if I manually created the deluge user first, you may need to. |
| 8 | * Please update this guide if you can improve it. |
| 9 | |
| 10 | == Upstart Jobs == |
| 11 | Put this in /etc/init/deluge.conf and set uid and gid to the user and group you wish to run deluge as: |
| 12 | {{{ |
| 13 | start on (filesystem and networking) or runlevel [2345] |
| 14 | stop on runlevel [016] |
| 15 | |
| 16 | env uid=deluge |
| 17 | env gid=deluge |
| 18 | |
| 19 | exec start-stop-daemon -S -c $uid:$gid -x /usr/bin/deluged -- -d |
| 20 | }}} |
| 21 | |
| 22 | This should be placed in /etc/init/deluge-web.conf, remember to set uid and gid to your preference: |
| 23 | {{{ |
| 24 | start on started deluge |
| 25 | stop on stopping deluge |
| 26 | |
| 27 | env uid=deluge |
| 28 | env gid=deluge |
| 29 | |
| 30 | exec start-stop-daemon -S -c $uid:$gid -x /usr/bin/deluge-web |
| 31 | }}} |
| 32 | |
| 33 | ==== Migration ==== |
| 34 | If you followed the old guide to make an init script, remove it: |
| 35 | {{{ |
| 36 | #!sh |
| 37 | sudo /etc/init.d/deluge-daemon stop |
| 38 | sudo rm /etc/init.d/deluge-daemon |
| 39 | sudo update-rc.d deluge-daemon remove |
| 40 | }}} |
| 41 | |
| 42 | ==== Start deluge ==== |
| 43 | {{{ |
| 44 | #!sh |
| 45 | sudo start deluge |
| 46 | }}} |
| 47 | |
| 48 | ==== Web UI ==== |
| 49 | * To prevent the web-ui starting automatically after deluge just remove the 'start on' line from deluge-web.conf. The web-ui can then be started (and stopped) manually with: |
| 50 | {{{ |
| 51 | #!sh |
| 52 | sudo start deluge-web # sudo stop deluge-web |
| 53 | }}} |
| 54 | |
| 55 | |
| 56 | == Logging == |
| 57 | Create a structure for deluge to log to: |
| 58 | {{{ |
| 59 | #!sh |
| 60 | sudo mkdir -p /var/log/deluge |
| 61 | }}} |
| 62 | Give the user that deluge is running as (in this case deluge) write-access to the logs: |
| 63 | {{{ |
| 64 | #!sh |
| 65 | sudo chmod -R 755 /var/log/deluge |
| 66 | sudo chown -R deluge /var/log/deluge |
| 67 | }}} |
| 68 | Edit the init confs like so: |
| 69 | {{{ |
| 70 | exec start-stop-daemon -S -c $uid:$gid -x /usr/bin/deluged -- -d -l /var/log/deluge/daemon.log -L warning |
| 71 | }}} |
| 72 | {{{ |
| 73 | exec start-stop-daemon -S -c $uid:$gid -x /usr/bin/deluge-web -- -l /var/log/deluge/web.log -L warning |
| 74 | }}} |
| 75 | * See [wiki:Faq#EnableDelugeLogging Logging] for possible log-levels. |
| 76 | |
| 77 | Restart the daemon: |
| 78 | {{{ |
| 79 | sudo restart deluge |
| 80 | }}} |
| 81 | |
| 82 | Tell logrotate to rotate the logs by putting this in /etc/logrotate.d/deluge: |
| 83 | {{{ |
| 84 | /var/log/deluge/*.log { |
| 85 | rotate 4 |
| 86 | weekly |
| 87 | missingok |
| 88 | notifempty |
| 89 | compress |
| 90 | delaycompress |
| 91 | sharedscripts |
| 92 | postrotate |
| 93 | initctl restart deluge >/dev/null 2>&1 || true |
| 94 | initctl restart deluge-web >/dev/null 2>&1 || true |
| 95 | endscript |
| 96 | } |
| 97 | }}} |