Deluge

This article will take you through the installation, usage, and customisation of the torrent client Deluge. For the most part no expertise is required to use the guide. Some areas will require being able to connect to your slot via SSH and you will be instructed to connect via SSH where this is the case.

Deluge works in two parts - a daemon and a means of controlling it. The daemon is the "engine" and is responsible for the core torrent-related functionality. There are three means of controlling the daemon - through a web UI, through a thin client remotely and through a console.

Table of contents

Installation

It is very simple to install or reinstall Deluge as the Feral web manager supports its installation. Please follow the separate guide to installing software from the web manager, selecting Deluge from the list.

You will need to download and install the thin client separately from Deluge's own download page. Simply select the operating system from the list and follow the installation guide for software on your operating system. You should select Python 2.7 where possible.

Accessing Deluge

Obtaining the Deluge daemon's details

However you choose to control the Deluge daemon it is likely that you'll need its details at some point. To get them, log in via SSH then copy and paste the following one-line command:

printf "10.0.0.1\n$(hostname -f)\n$(whoami)\n$(sed -rn 's/(.*)"daemon_port": (.*),/\2/p' ~/.config/deluge/core.conf)\n$(sed -rn "s/$(whoami):(.*):(.*)/\1/p" ~/.config/deluge/auth)\n"

The output of that command will be 5 separate lines. The first will always be 10.0.0.1. Whilst in reality you'll get your actual details returned for the other four, in order to explain what each one means these have been reduced to 4 separate variables:

  • hostname
  • user
  • port
  • password

Those variables are defined as follows:

host
The hostname of the server you are on. Used for connecting the daemon from somewhere other than your slot, such as the thin client.
user
Your username for the Deluge daemon.
port
The port that the Deluge daemon is running on. This will be different for each user.
password
The Deluge daemon password. It is not the same thing as the web UI password.

The following sections rely on you being able to obtain this information and they each use the variables described above.

Web UI

To access the web UI simply visit the link as provided on your slot's software page. This will be in the format https://server.feralhosting.com/user/deluge/, where server is the name of your server and user is your username.

If for some reason the daemon has been removed from your web UI connection manager, you can add it by clicking on Connection Manager and adding the requested information. For host, you can use 10.0.0.1. For the other fields use the corresponding information from the section Obtaining the Deluge daemon's details.

Thin client

To configure the Deluge daemon in the thin client simply supply the information for host in the field hostname, together with user, port and password as in the section Obtaining the Deluge daemon's details.

The thin client 2.x is not backwards compatible with 1.x versions. Feral runs a 1.x version to avoid breaking existing set ups.

Console

This article's coverage of the console only extends to running it on your slot via SSH. It should in principle be possible to do entirely remotely but probably does not add much value above the existing options. This is particularly the case for Windows since deluge-console.exe cannot be run in interactive mode (i.e. the user must pass commands individually and then manually check to see the current status of torrents).

To access the console via SSH, log in to your slot and run deluge-console. You will initially get an error stating Failed to connect to 127.0.0.1:58846 with reason: Connection refused. This is because the software tries Deluge's default daemon values, whereas for obvious reasons Feral needs to change these for each user.

To connect to your daemon, replace the following variables with the information you got in the section Obtaining the Deluge daemon's details:

connect 10.0.0.1:port user password

Starting, stopping and restarting

As described in the introduction Deluge runs in two parts, the daemon and some means of controlling it. This section covers starting, stopping and restarting the Deluge daemon (process name deluged). It is not possible to restart the web UI since it doesn't actually run on your accessible slot. You must therefore let the system start the web UI.

Every five minutes the system will scan the processes running and if either the Deluge daemon or web UI is not running it will attempt to start them up. If you need to start, stop or restart the Deluge daemon you can do so by logging in via SSH and executing the following commands.

start
deluged
check running
pgrep -fu "$(whoami)" "deluged"
stop
pkill -fu "$(whoami)" 'deluged'
restart
pkill -fu "$(whoami)" 'deluged' && sleep 3 && deluged
kill (force stop)
pkill -9 -fu "$(whoami)" 'deluged'

If you get any errors running these commands please check the troubleshooting section.

The check running command will return a process number if the Deluge daemon is running. If it doesn't return anything, the Deluge daemon is not running.

Usage

This section provides information on the most basic use of Deluge. It generally tackles things in the order web UI, thin client, console.

Basic considerations

Deluge prioritises downloading over uploading, particularly if the disk is under heavy load. The priority for Deluge is to increase availability for the swarm. For this reason and for improved performance in general, it does follows that you see do not best speeds by setting the number of possible connections to a high or unlimited number. You would be more likely hurting than helping yourself by setting a high number since disk activity is required in the creation and maintenance of connections.

Whilst Deluge is a solid choice for lower numbers of torrents it can become unstable or sluggish at higher numbers. It is not possible to pinpoint an exact number, but at around 600 is when you may start to see effects. As the torrent numbers increase, so does the chance for instability and sluggishness. If you need to run a higher number of torrents you should perhaps consider your options - running multiple instances of Deluge (see the specific section below) or running Deluge together with rTorrent.

Please note that since it is the daemon running on your Feral space which does the actual torrent work, you do not need to keep your computer running if you wish to use the thin client. You would simply use the thin client when you wanted to add or remove torrents; when you shut your machine down the daemon will continue downloading or uploading.

If you decide to use the console, you can quit it by typing quit and pressing enter.

Adding torrents

If you're using the web UI, click on the Add button on the top of the UI to bring up the Add Torrents dialog. You can add multiple torrents if you so wish and can add either via a .torrent file or directly via a URL.

In the thin client the button is a large + sign with tooltip text which reads Add torrent. You can also press ctrl + O to bring up the dialog.

Things are done in the console using commands. To add a torrent, use add. You can get help for any commands (including add) using the option -h:

add -h
Usage: add [-p <save-location>] <torrent-file/infohash/url> [<torrent-file/infohash/url> ...]

Options:
  -p PATH, --path=PATH  save path for torrent
  -h, --help            show this help message and exit

Add a torrent

The options should be fairly simple - those surrounded by [ and ] are not mandatory - use them only if you want to. So, if you want a save location different to your default one, use the -p option, otherwise you can leave it. Replace <torrent-file/infohash/url> with a torrent location on your slot, an infohash or a URL.

Removing torrents

In both the web UI and the thin client, select the torrent or torrents you wish to remove from the list of torrents. Then, right click and select Remove Torrent. You'll then be presented to three options:

Cancel
Take no action - no torrents are removed
Remove with Data
The torrent is removed completely - from Deluge and your slot in general
Remove Torrent
The torrent is removed from Deluge, but its data remains on your slot.

If you use the console, use the rm command and its associated options:

>>> rm -h
Usage: rm <torrent-id>

Options:
  --remove_data  remove the torrent's data
  -h, --help     show this help message and exit

Remove a torrent

The torrent-id should be replaced with either the name or the hash of the torrent. You can type rm and then press the tab key twice to list the torrent names and their hashes, or first execute info to display the torrents and their information (including ID hashes). If you also want to remove the data from the disk itself, remember to specify --remove_data.

Plugins

A separate article covers installing plugins for Deluge.

Upgrading and downgrading

Feral does not support any other version of Deluge than the one installable via the web manager. If a new version comes out which you want to switch to, or you need an earlier version for some reason, you'll need to install it manually.

Please note the following, when installing custom versions of Deluge:

  • You should first install the version from the web manager if you want to use the web UI.
  • You'll need to manually manage the starting and restarting of the Deluge daemon.
  • Custom versions will only work with Deluge 1.x

Installing a custom version

To install the custom version you need to grab the source from the Deluge source download listing. Replace deluge_source in the first command below with the .tar.gz file representing the version you want. Run the following commands whilst connected to your slot via SSH:

wget -qO ~/deluge-tmp.tar.gz deluge_source
mkdir ~/deluge-tmp && tar xf ~/deluge-tmp.tar.gz  --strip-components=1 -C ~/deluge-tmp && cd ~/deluge-tmp/
python setup.py install --user
cd && rm -rf ~/deluge-tmp*

Configuring the custom version before use

sed -i 's|"daemon_port": 58846|"daemon_port": '$(shuf -i 10001-32001 -n 1)'|g' ~/.config/deluge/core.conf
sed -i 's|"download_location": "$(pwd)/Downloads"|"download_location": "$(pwd)/private/deluge/data"|g' ~/.config/deluge/core.conf
sed -i 's|"autoadd_location": "$(pwd)/Downloads"|"autoadd_location": "$(pwd)/private/deluge/watch"|g' ~/.config/deluge/core.conf
sed -i 's|"torrentfiles_location": "$(pwd)/Downloads"|"torrentfiles_location": "$(pwd)/private/deluge/watch"|g' ~/.config/deluge/core.conf
sed -i 's|"max_connections_global": 200|"max_connections_global": 40|g' ~/.config/deluge/core.conf
echo "$(whoami):$(< /dev/urandom tr -dc '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' | head -c20; echo;):10" > ~/.config/deluge/auth
printf "10.0.0.1\n$(hostname -f)\n$(whoami)\n$(sed -rn 's/(.*)"daemon_port": (.*),/\2/p' ~/.config/deluge/core.conf)\n$(sed -rn "s/$(whoami):(.*):(.*)/\1/p" ~/.config/deluge/auth)\n"

The final command will print the access details which you can use as per the section Accessing Deluge.

Starting the custom instance

The custom instance of can be started by running ~/.local/bin/deluged. It can be stopped as per the main section Starting, stopping and restarting

Running multiple instances of Deluge

Feral can only support the instance of Deluge as installed via the web manager. However, it should still be possible to install and run further instances. The lack of support means that only general help (in addition to that given by this article) can be given if you open a ticket.

To execute the commands given in this section you will need to log on via SSH.

You are not limited to one extra instance - simply follow the steps replacing deluge2 with deluge3 and so on (or indeed any other name you wish).

Creating directories and copying existing files

The initial steps are simply to create the necessary directories in ~/private for the new instance of Deluge as well as copying the existing instance's config files to make things a little easier on us. Copy and paste the following:

mkdir -p ~/private/deluge2/{completed,data,torrents,watch}
cp -r ~/.config/deluge ~/.config/deluge2

Configuring the new instance

Some of the files copied as part of the last section are unnecessary and should be removed. We also need to alter the configuration a little bit. Copy and paste the following.

rm -f ~/.config/deluge2/deluged.pid
rm -f ~/.config/deluge2/state/*.torrent
sed -i 's|/private/deluge/|/private/deluge2/|g' ~/.config/deluge2/core.conf
sed -i 's|/.config/deluge/|/.config/deluge2/|g' ~/.config/deluge2/core.conf
sed -i 's|"daemon_port":.*,|"daemon_port": '$(shuf -i 10001-32001 -n 1)',|g' ~/.config/deluge2/core.conf

Accessing the new instance

Firstly, print the details for the new instance by copying and pasting the following:

printf "10.0.0.1\n$(hostname -f)\n$(whoami)\n$(sed -rn 's/(.*)"daemon_port": (.*),/\2/p' ~/.config/deluge2/core.conf)\n$(sed -rn "s/$(whoami):(.*):(.*)/\1/p" ~/.config/deluge2/auth)\n"

Then, start up the new instance by copying and pasting this command:

deluged -c ~/.config/deluge2/

You can then add the details to your access method of choice (web UI, thin client or console) as per the section Accessing Deluge.

Starting the extra instance

The extra instance of can be started by running deluged -c ~/.config/deluge2/. It can be stopped as per the main section Starting, stopping and restarting, swapping "deluged" with "deluge2" in the commands.

Automatically restarting custom instances

Whilst the main instance of Deluge installable via the web manager will be started automatically, cron jobs can be used to check if custom daemons are running and start them up if they are not. There is a separate page on configuring cron jobs.

Troubleshooting

Restarting the Deluge daemon gives the error Couldn't listen on any:port: Errno 98 Address already in use.

In the error above, port is replaced by a number (likely beginning 52 or 53). The error means another process, perhaps another user's, is running on that process. Please open a ticket quoting the error message and staff will investigate.

In the web UI I get the error "The connection to the webserver has been lost!"

This error can have a number of causes. It might just be that the Deluge daemon needs restarting. This seems particularly to be the case if the daemon has been running for a long time. Please see the section above, Starting, stopping and restarting.

It might also be that you're running too many torrents for Deluge to handle and stability is suffering as a result. You can either create another instance as per the guide 'Running multiple instances of Deluge' or migrate to another torrent client. Please note that it's perfectly possible to run different clients side-by-side without issue.

Uninstalling

pkill -9 -fu "$(whoami)" 'deluged'
pkill -9 -fu "$(whoami)" 'deluge-web'
rm -rf ~/.config/deluge ~/private/deluge

These commands act only on your slot, so the software page will not change to reflect the fact that Deluge has been removed. The URL and password will remain despite the fact that Deluge is gone.