Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

sallyswiss
Copy link

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.

… 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.
@rtorrentuser
Copy link

Works fine! Thank you!

@jenkins101
Copy link

implements FR #36

@Tatsh
Copy link

Tatsh commented Mar 11, 2013

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

@grantemsley
Copy link

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

@jenkins101
Copy link

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?

@jenkins101
Copy link

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[0]=='~'))                                            
                                                                $this->directory = $this->home.substr($this->directory,1);             
                                                        $req = new rXMLRPCRequest(new rXMLRPCCommand( "execute", array("rm",$randName) 
                                                        $req->run();                                                                   
                                                }                                                                                      
                                                else                                                                                   
                                                        $this->idNotFound = true;                                                      
                                        }                                                                                              

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

@jenkins101
Copy link

@sallyswiss you got any ide?

@jenkins101
Copy link

does not work if started from python...

@rakshasa
Copy link
Owner

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

@wheelerlaw
Copy link

What is the status of this?

@rakshasa
Copy link
Owner

rakshasa commented May 16, 2016

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
Copy link

o6uoq commented Jun 14, 2016

+1

rakshasa added a commit that referenced this pull request Jun 26, 2016
Allow rtorrent to run as a daemon, slightly modified version of #111
@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants