[Unit] Description=rTorrent After=network.target [Service] Type=forking KillMode=none User={{ ansible_ssh_user }} # FIXME Start-pre gives an 'Operation not supported error' #ExecStartPre=/usr/bin/bash -c "if test -e %h/.rtorrent_session/rtorrent.lock && test -z `pidof rtorrent`; then rm -f %h/.rtorrent_session/rtorrent.lock; fi" ExecStart=/usr/bin/screen -dmfa -S rtorrent /usr/bin/rtorrent ExecStop=/usr/bin/bash -c "test `pidof rtorrent` && killall -w -s 2 /usr/bin/rtorrent" WorkingDirectory=%h Restart=on-failure [Install] WantedBy=multi-user.target