Rtorrent: [Feature request] add systemd service file

Created on 16 Mar 2019  路  8Comments  路  Source: rakshasa/rtorrent

Hi,

since #446 there is a new feature Daemon Mode as shortly explained here.

Could you provide a systemd service file in the git an make it part of the release tarball, something that will looks like:

[Unit]
Description=rTorrent Daemon
After=network.target

[Service]
Type=simple
KillMode=forking
User=sdbox
ExecStart=/usr/bin/rtorrent -o system.daemon.set=true
WorkingDirectory=%h
Restart=on-failure

[Install]
WantedBy=multi-user.target

Related issues

  • This would close: systemd support #372
  • This would avoid issues like: screen init script issue #803 and Cannot start rtorrent service (systemd Ubuntu 18.10) #829
  • This would help distributions to package the software: for example for ArchLinux https://bugs.archlinux.org/task/61929

Most helpful comment

Refined the rtorrentd.service file to this:

[Unit]
Description=rTorrent Daemon
After=network-online.target local-fs.target

[Service]
User=rtorrent
Group=rtorrent
Type=simple
KillMode=process
ExecStart=/usr/bin/rtorrent -n -o import=/etc/rtorrent.d/rtorrent.rc
WorkingDirectory=%h
Restart=on-failure

[Install]
WantedBy=multi-user.target

However this still leaves us to create a /etc/rtorrent.d/rtorrent.rc default file (containing atleast system.daemon.set = true). I do prefer that to passing -o system.daemon.set=true since we should anyways promote system-wide configuration settings for a daemon.

All 8 comments

It should come disabled by default.
Lots of people use external HDDs to store their torrents.
Also, there should also be a SysV version as well, if you want to implement it.

It should come disabled by default.

I'm just talking about providing, I don't understand what you mean.

Lots of people use external HDDs to store their torrents.

what does this have to do with it ?

Also, there should also be a SysV version as well, if you want to implement it.

Yeah you could open an issue for a sysV or openrc script as well.

I recently modified the one i use to run rTottent as a daemon:

[Unit]
Description=rTorrent
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
KillMode=process
User=rtorrent
PIDFile=/run/rtorrent.pid
ExecStartPre=/bin/bash -c "if test -e /media/lv2/download/.session/rtorrent.lock && test -z pidof rtorrent; then rm -f /media/lv2/download/.session/rtorrent.lock; fi"
ExecStart=/usr/local/bin/rtorrent
WorkingDirectory=%h
Restart=on-failure

[Install]
WantedBy=multi-user.target

If you do not want ExecStartPre you can set in .rtorrent.rc the following:

session.use_lock.set = no

Make a pull request.

@mirolm you do not use system.daemon.set=true

Make a pull request.

I didn't managed to get it work, that's why I opened a feature request instead of a PR.

@noraj yes it is included in my .rtorrent.rc that's why it is not there.

I noticed that rtorrent is more responsive in daemon mode, but harder to debug if something happens. Kudos for this setting.

Refined the rtorrentd.service file to this:

[Unit]
Description=rTorrent Daemon
After=network-online.target local-fs.target

[Service]
User=rtorrent
Group=rtorrent
Type=simple
KillMode=process
ExecStart=/usr/bin/rtorrent -n -o import=/etc/rtorrent.d/rtorrent.rc
WorkingDirectory=%h
Restart=on-failure

[Install]
WantedBy=multi-user.target

However this still leaves us to create a /etc/rtorrent.d/rtorrent.rc default file (containing atleast system.daemon.set = true). I do prefer that to passing -o system.daemon.set=true since we should anyways promote system-wide configuration settings for a daemon.

Was this page helpful?
0 / 5 - 0 ratings