You are not logged in.

#1 2012-09-20 12:29:23

chuck79
Member
Registered: 2012-09-20
Posts: 11

systemd, rtorrent WITH screen

Hi all,

I create a custom systemd service file, to run rtorrent into screen, but not work. "journalctl" said "terminated" and/or "failed", but no detailed message. Here is the code:

[Unit]
Description=rtorrent Service
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/sudo -u raspi /usr/bin/screen -d -RR /usr/bin/rtorrent

[Install]
WantedBy=multi-user.target

I tried with "forking" type instead of "oneshot", but same result. Then I tried "User=raspi", but not work. (The user name and the path's is correct)

What's the problem?

I use this article.

Offline

#2 2012-09-20 12:41:12

Awebb
Member
Registered: 2010-05-06
Posts: 6,309

Re: systemd, rtorrent WITH screen

does "screen -d -RR /usr/bin/bash -c /usr/bin/rtorrent" work?

Offline

#3 2012-09-20 12:47:40

chuck79
Member
Registered: 2012-09-20
Posts: 11

Re: systemd, rtorrent WITH screen

Thanks, I will try it.

Offline

#4 2012-09-20 12:58:52

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: systemd, rtorrent WITH screen

First, Type=oneshot is wrong. It will terminate all remaining processes after the initial process returns - you need Type=forking. Second, do not use sudo (or su) inside a systemd unit, there are User= and Group= switches.

Finally, you are trying to launch a screen session, which requires a tty - which systemd does not give you. You must launch a detached screen session using

ExecStart=/usr/bin/screen -S rtorrent -dm /usr/bin/rtorrent

Reading the screen manpage, it might even be useful to not fork when using systemd: Remove the Type= statement and use

ExecStart=/usr/bin/screen -S rtorrent -Dm /usr/bin/rtorrent

Offline

#5 2012-10-08 08:55:35

GutenYe
Member
From: China
Registered: 2011-11-27
Posts: 44
Website

Re: systemd, rtorrent WITH screen

tested.

$ edit rtorrent@.server

[Unit]
Description=rtorrent Service
After=network.target

[Service]
Type=forking
User=%i
ExecStart=/usr/bin/screen -dmS rtorrent rtorrent
ExecStop=/usr/bin/screen -S rtorrent -X quit

[Install]
WantedBy=multi-user.target

$ systemctl start rtorrent@user


Linux, Vim, Ruby, Javascript and Go.

Offline

Board footer

Powered by FluxBB