Im having troubleshooting configuring systemd with rtorrent and screen in my raspberry pi.
I have the service unit file configured and when i start it manually with systemctl start rtorrent
it starts successfully, but the problem is that the service fail to start on reboot, so i have to manually start it always.
Of course, I have enabled the service with systemctl enable rtorrent
Here the service unit definition:
[Unit]
Description=rTorrent
After=network.target
[Service]
Type=forking
User=rtorrent
Group=rtorrent
KillMode=none
ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent
WorkingDirectory=/home/rtorrent/
Restart=on-failure
[Install]
WantedBy=network-online.target
On boot there is the systemctl status rtorrent
output
● rtorrent.service - rTorrent
Loaded: loaded (/etc/systemd/system/rtorrent.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-01-04 16:51:20 GMT; 1min 0s ago
Process: 567 ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent (code=exited, status=0/SUCCESS)
Process: 571 ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent (code=exited, status=1/FAILURE)
Main PID: 568 (code=exited, status=0/SUCCESS)
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Service RestartSec=100ms expired, scheduling restart.
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Scheduled restart job, restart counter is at 5.
Jan 04 16:51:20 raspberry systemd[1]: Stopped rTorrent.
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Start request repeated too quickly.
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Failed with result 'exit-code'.
Jan 04 16:51:20 raspberry systemd[1]: Failed to start rTorrent.
And here the journalctl --unit=rtorrent
output
Jan 04 16:51:19 raspberry killall[571]: /usr/bin/rtorrent: no process found
Jan 04 16:51:19 raspberry systemd[1]: rtorrent.service: Control process exited, code=exited, status=1/FAILURE
Jan 04 16:51:19 raspberry systemd[1]: rtorrent.service: Failed with result 'exit-code'.
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Service RestartSec=100ms expired, scheduling restart.
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Scheduled restart job, restart counter is at 5.
Jan 04 16:51:20 raspberry systemd[1]: Stopped rTorrent.
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Start request repeated too quickly.
Jan 04 16:51:20 raspberry systemd[1]: rtorrent.service: Failed with result 'exit-code'.
Jan 04 16:51:20 raspberry systemd[1]: Failed to start rTorrent.
Jan 04 16:52:27 raspberry systemd[1]: Starting rTorrent...
Jan 04 16:52:27 raspberry systemd[1]: Started rTorrent.
It says that the rtorrent binary cannot be found, but it exists
-rwxr-xr-x 1 rtorrent rtorrent 1134120 Jun 28 2018 /usr/bin/rtorrent
and if i run systemctl start rtorrent
it start succesfully
● rtorrent.service - rTorrent
Loaded: loaded (/etc/systemd/system/rtorrent.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-01-04 16:52:27 GMT; 8min ago
Process: 924 ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent (code=exited, status=0/SUCCESS)
Main PID: 925 (screen)
Tasks: 4 (limit: 2200)
Memory: 4.7M
CGroup: /system.slice/rtorrent.service
├─925 /usr/bin/SCREEN -d -m -fa -S rtorrent /usr/bin/rtorrent
└─926 /usr/bin/rtorrent
Jan 04 16:52:27 raspberry systemd[1]: Starting rTorrent...
Jan 04 16:52:27 raspberry systemd[1]: Started rTorrent.
I've also found that if i change the "User=pi" its starts on boot, but the process run with the pi user and i dont want it...
If i start it manually the process is executed by the rtorrent user, its what i want on boot :S
rtorrent 925 0.0 0.2 8132 2104 ? Ss 16:52 0:00 /usr/bin/SCREEN -d -m -fa -S rtorrent /usr/bin/rtorrent
rtorrent 926 0.1 1.5 85136 14596 pts/1 Ssl+ 16:52 0:00 /usr/bin/rtorrent
killall
saying it could not find any process with that name to kill. It does check that a corresponding binary exists first, and if it doesn't, says "No such file or directory", not "no process found".