Page 1 of 1

How to run qbittorrent-nox on startup using systemd?

Posted: Fri Sep 25, 2015 8:59 pm
by snakyjake
I'm following these directions to setup QBT to start on boot.

The directions say:
Warning! Ubuntu 15.04 switched to Systemd, do not use the script below with 15.04, it will be corrected.
How do I use systemd to automatically start QBT as a service during startup/boot?
Or do I ignore the warning and proceed with the init.d script?

Thanks,
Jake

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Fri Sep 25, 2015 11:16 pm
by snakyjake
Does the daemon user require a home directory?
Where does the daemon store the configuration files?

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Sat Sep 26, 2015 2:45 am
by snakyjake
Something that is confusing me is these two wiki instructions pages:

https://github.com/qbittorrent/qBittorr ... t-X-server
https://github.com/qbittorrent/qBittorr ... -interface

Both of the wiki's mention the init.d script, but with different names.

Which is the right answer:

A) /etc/init.d/qbittorrent
B) /etc/init.d/qbittorrent-nox-daemon

Jake

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Sat Sep 26, 2015 2:57 pm
by snakyjake
I've been trying to follow this example:
https://github.com/qbittorrent/qBittorr ... service.in

I run:

Code: Select all

sudo service qbittorrent start
Get message:
Failed to start qbittorrent.service: Unit qbittorrent.service failed to load: No such file or directory.
Where did the error come frome?  Ubuntu or QBT?
What file is it looking for? 
Where?

I put the file "qbittorrent-nox.service" in "/etc/systemd/system/".  This is where all the other service files are.  However, the URL above doesn't mention "system".  The file ends with ".in", but the other service files don't. 

Not sure if I'm on the right track to figure this out, and I'm definitely in the weeds.

Jake

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Sat Sep 26, 2015 5:31 pm
by snakyjake
Here is my start script:

Code: Select all

# /etc/systemd/system/qbittorrent.service
[Unit]
Description=qBitTorrent
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/qbittorrent-nox --daemon
User=qbt
Group=bt

[Install]
WantedBy=multi-user.target
If I manually run /usr/bin/qbittorrent-nox --daemon, it works:

Code: Select all

jake@BROWN:/var/torrent$ /usr/bin/qbittorrent-nox --daemon
Maybe something to do with the user and permissions?  But I don't receive any error messages that indicate a user or permission problem:

Code: Select all

jake@BROWN:/var/torrent$ sudo service qbittorrent status
? qbittorrent.service - qBitTorrent
   Loaded: loaded (/etc/systemd/system/qbittorrent.service; enabled; vendor preset: enabled)
   Active: failed (Result: core-dump) since Sat 2015-09-26 10:26:21 PDT; 31s ago
  Process: 25770 ExecStart=/usr/bin/qbittorrent-nox --daemon (code=exited, status=0/SUCCESS)
 Main PID: 25771 (code=dumped, signal=ABRT)

Sep 26 10:26:21 BROWN systemd[1]: Starting qBitTorrent...
Sep 26 10:26:21 BROWN systemd[1]: Started qBitTorrent.
Sep 26 10:26:21 BROWN systemd[1]: qbittorrent.service: main process exited, code=dumped, status=6/ABRT
Sep 26 10:26:21 BROWN systemd[1]: Unit qbittorrent.service entered failed state.
Sep 26 10:26:21 BROWN systemd[1]: qbittorrent.service failed.
Jake

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Sun Sep 27, 2015 6:50 am
by snakyjake
Finally figured it out, and got it working.
Been through the weeds on this, and I'll update my solution when I get some sleep.

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Sun Sep 27, 2015 12:26 pm
by ciaobaby
and I'll update my solution when I get some sleep.
Posting it on, or updating  the "Wiki" as well would be useful.

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Mon Sep 28, 2015 5:48 pm
by snakyjake
Here are my notes...I tried a bunch of things to get this to work, but think this is what got me working...

1) qbittorrent.service
Use the qbittorrent.service from link.
Store the qbittorrent.service in the location /etc/systemd/system/qbittorrent.service

I didn't use the User=1000.
User=qbtuser
Group=bt

I saw other examples of "nice" and "umask", and not sure what that would do.

2) User

Now here's the big one...I think this is why I couldn't get it to work.
QBT service runs under a user account (e.g. qbtuser).  The config and other files will be stored /home/qbtuser/

At first I didn't have the qbtuser account.  Later I created the account as a system account without a home directory.  Then eventually I gave the user a home directory, and things started working.

Jake

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Mon Nov 30, 2015 8:08 pm
by pointer2null
I'm hainvg issues getting this working as well.

Host OS: Debian 8.

Have installed qbittorrent-nox from repo and if I run direct in the shell it's fine.

So have seen Jakes comments and created a qbittorrent.service file

Code: Select all

root@gdserver:/etc/systemd/system# cat qbittorrent.service
[Unit]
Description=qBittorrent Daemon Service
After=network.target

[Service]
Type=forking
User=qbtuser
Group=www-data
ExecStart=/usr/bin/qbittorrent-nox --webui-port=8099 -d

[Install]
WantedBy=multi-user.target

The problem I get is that qbittorrent starts and exits immediately.

Code: Select all

root@gdserver:/etc/systemd/system# systemctl start qbittorrent.service
root@gdserver:/etc/systemd/system# systemctl status qbittorrent.service
? qbittorrent.service - qBittorrent Daemon Service
   Loaded: loaded (/etc/systemd/system/qbittorrent.service; enabled)
   Active: inactive (dead) since Mon 2015-11-30 20:03:23 GMT; 1s ago
  Process: 2348 ExecStart=/usr/bin/qbittorrent-nox --webui-port=8099 -d (code=exited, status=0/SUCCESS)
 Main PID: 2349 (code=exited, status=0/SUCCESS)
root@gdserver:/etc/systemd/system# cat /var/log/qbittorrent-nox.log

*** Legal Notice ***
qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.

No further notices will be issued.

Press 'y' key to accept and continue...

*** Legal Notice ***
qBittorrent is a file sharing program. When you run a torrent, its data will be made available to others by means of upload. Any content you share is your sole responsibility.

No further notices will be issued.

Press 'y' key to accept and continue...
Anyone seen this? Any ideas?

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Mon Nov 30, 2015 8:58 pm
by pointer2null
Solved - the Group= was set wrong. D'oh

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Thu Feb 04, 2016 12:03 am
by morfikov
I have the following .service file:

Code: Select all

[Unit]
Description=qbittorrent-nox
Documentation=man:qbittorrent-nox
DefaultDependencies=yes
Requires=media-Kabi.mount media-Grafi.mount
After=media-Kabi.mount media-Grafi.mount network-online.target nss-lookup.target
Before=multi-user.target

[Service]
User=morfik
Group=p2p
Type=simple
ExecStart=/usr/bin/qbittorrent-nox
Nice=19
IOSchedulingClass=idle
CPUShares=256
StartupCPUShares=256
MemoryLimit=50M
BlockIOWeight=128
Slice=p2p.slice
StandardError=null
StandardOutput=null
TimeoutSec=10s

[Install]
WantedBy=multi-user.target
I think it self explanatory.

Re: How to run qbittorrent-nox on startup using systemd?

Posted: Sun Feb 28, 2016 9:47 pm
by NeoMod
Here it is a more generic version of the .service file, also with instructions on how to set-up:

1) In order to create the .service file you can use the following command from terminal:

Code: Select all

sudo nano /etc/systemd/system/qbittorrent.service
2) Once created, copy the following basic .service configuration and paste it inside the previously created file:

Code: Select all

[Unit]
Description=qbittorrent-nox
Documentation=man:qbittorrent-nox
DefaultDependencies=yes
After=network-online.target nss-lookup.target
Before=multi-user.target

[Service]
User=[i][b]insertyourusername[/b][/i]
Group=[b]insertyourusergroup[/b]
Type=simple
ExecStart=/usr/bin/qbittorrent-nox [-options]
Nice=10
StandardError=null
StandardOutput=null
TimeoutSec=360s

[Install]
WantedBy=multi-user.target
3) Before saving, please modify the user and usergroup variables to fit your own needs. Also, remember to pass any options to the qbittorrent-nox deamon  by appending them at the end of the ExecStart line. ( for example, if you want to use a different port then add the --webui-port=8082 at the end of the line. The complete line should then read: ExecStart=/usr/bin/qbittorrent-nox --webui-port=8082).

4) Use the following command to update systemctl service and create symlinks:

Code: Select all

sudo systemctl enable qbittorrent.service
5) Finally run qbittorrent-nox using the following command:

Code: Select all

sudo service qbittorrent start

Please note:


The example .service file provided by morfikov is more complex since it uses various functions such as Requirements, IOScheduling and CPUShares. But if you are not acquainted with your hardware and/or with advanced features of .service I suggest using the basic configuration listed above.
(also, each hardware works differently so, for example, my settings on a LeMaker Banana Pro might not be optimal on a Raspberry Pi....)