rakshasa / rtorrent

rTorrent BitTorrent client
https://github.com/rakshasa/rtorrent/wiki
GNU General Public License v2.0
4.18k stars 415 forks source link

[Feature request] add systemd service file #844

Open noraj opened 5 years ago

noraj commented 5 years ago

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

ghost commented 5 years ago

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.

noraj commented 5 years ago

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.

mirolm commented 5 years ago

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

rakshasa commented 5 years ago

Make a pull request.

noraj commented 5 years ago

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

noraj commented 5 years ago

Make a pull request.

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

mirolm commented 5 years ago

@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.

vilgotf commented 5 years ago

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.