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.
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
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 
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
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
it works if I start it in a screen
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));
$this->gid = explode(' ',trim($line));
$this->home = trim($line);
$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?
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.