Allow rtorrent to run as a daemon without screen. implements issue #36 #111

wants to merge 1 commit into


None yet

8 participants


this checks if running in a terminal before initializing ncurses with initscr and then does not initialize if not a terminal. this means rtorrent can run as a daemon but will still function normally under normal conditions.

@sallyswiss sallyswiss allow rtorrent to run as a daemon without screen. check for available…
… terminal before initializing ncurses by calling initscr. if no terminal available assume rtorrent is daemon and disable terminal functionality in display::Canvas so program does not crash and i/o can be done with rpc calls.

Works fine! Thank you!


implements FR #36

Tatsh commented Mar 11, 2013

No more screen hackage to make it run as a daemon? 👍


Works great! Thank you so much. Instead of a hacked together script to get it running through screen, rtorrent can be controlled with a simple upstart script now!

Below is my upstart script in /etc/init/rtorrent, in case it helps anyone. You'll probably want to change the paths and user/group:

description "rTorrent bittorrent client"

start on runlevel [2345]
stop on runlevel [!2345]

# Attempt to respawn, but if it failes 5 times in 10 seconds, stop permenantly
respawn limit 5 10

# Wait 90 seconds before killing rtorrent, it can take awhile to shut down properly
kill timeout 90

# Run as the rtorrent user
setuid rtorrent
setgid rtorrent
env HOME=/home/rtorrent

exec /usr/bin/rtorrent

this does not work for me?

I am trying to start it from a regular shell script

or it does start and seems to work but when I try to connect with rutorrent web-ui I get lots of errors and no listings

screenshot from 2013-04-29 23 41 31

it works if I start it in a screen

any ides?


here is were it seams to fail... of it helps

                             $randName = uniqid("/tmp/rutorrent-stats-".rand());                                    
                                                $id = getExternal('id');                                                               
                                                $req = new rXMLRPCRequest(                                                             
                                                        new rXMLRPCCommand("execute",array("sh","-c",$id." -u > ".$randName." ; ".$id."
                                                if($req->run() && !$req->fault && (($line=file($randName))!==false) && (count($line)>2)
                                                        $this->uid = intval(trim($line[0]));                                           
                                                        $this->gid = explode(' ',trim($line[1]));                                      
                                                        $this->home = trim($line[2]);                                                  
                                                        if(!empty($this->directory) &&                                                 
                                                                $this->directory = $this->home.substr($this->directory,1);             
                                                        $req = new rXMLRPCRequest(new rXMLRPCCommand( "execute", array("rm",$randName) 
                                                        $this->idNotFound = true;                                                      

the file /tmp/rutorrent-stats-".rand() is created with correct values so it has to be the return codes or so...


@sallyswiss you got any ide?


does not work if started from python...


In any case the 'have term' needs to be a variable that can be set (see src/command_*.cc) and default to true.


What is the status of this?

rakshasa commented May 16, 2016 edited

Status is that the patch defaults to daemon while that should be the non-default option set by a properly named system.daemon.enable variable (or something).

For someone who wants this merged, fork the branch, merge the latest develop, then add the (very easy to add) variable and checks to have the proper behavior.

Make a new pull request, attribute the original developers above, and make something I want to merge.

o6uoq commented Jun 14, 2016


@rakshasa rakshasa closed this Jun 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment