You are not logged in.

#1 2011-09-18 13:24:48

netrunner
Member
Registered: 2010-04-23
Posts: 5

[SOLVED] rtorrent daemon with tmux

Hi everyone,

I'm using arch for a couple of years now, and have never had a problem I could not fix by simply reading the wiki/forums.
However I'm already a couple of days trying to get an rtorrent daemon working without success. Hence my first post here.
As far as I know, the way to get rtorrent working as a daemon is using either screen, dtach, tmux or something similar (please correct me if I'm wrong).

The goal is to run rtorrent on my server at home and control it remotely with rutorrent. Both are currently installed and working.

I looked at the wiki and used the daemon posted there as an example, but modified as indicated to use tmux instead of screen, as follows:

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Starting rtorrent"
    su netrunner -c 'tmux -d -s rtorrent rtorrent' &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon rtorrent
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping rtorrent"
    killall -w -s 2 /usr/bin/rtorrent &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon rtorrent
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

This however does not seem to work. rtorrent does not start. (I do not see the process with top, and rutorrent reports a broken link with rtorrent)

I have tried to run the command directly:

$ tmux -d -s rtorrent rtorrent

...to check if the command was actually working, but I get:

usage: tmux [-28lquvV] [-c shell-command] [-f file] [-L socket-name]
            [-S socket-path] [command [flags]]

Has somebody any idea why this is not working? I'm new to both rtorrent and tmux, so I don't know exactly where to start looking for a solution.
Is it possible to run rtorrent as a daemon without tmux (or similar)?

Thanks in advance for your help!

Last edited by netrunner (2011-09-19 07:09:35)

Offline

#2 2011-09-18 18:41:00

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] rtorrent daemon with tmux

You need to start a new session with tmux, with rtorrent running: see the session initialization section of the wiki:
https://wiki.archlinux.org/index.php/Tm … ialization

Your line should look like (although I don't understand why you want to start it detached...)

tmux new -s rtorrent -d rtorrent

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2011-09-18 20:06:31

netrunner
Member
Registered: 2010-04-23
Posts: 5

Re: [SOLVED] rtorrent daemon with tmux

Thank you jasonwryan that worked like a charm!

[...] although I don't understand why you want to start it detached...

I'm not sure about it either. I'm new to tmux and do not really know the details (I simply took the line from the wiki...).
I read about the detach functionality of tmux but do not entirely understand its purpose.
Could you maybe elaborate on it in the context above? As a note that may be relevant, I'm running rtorrent on a headless server and ssh to it.

Anyway, thank you very much for your help.

Offline

#4 2011-09-18 20:51:06

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] rtorrent daemon with tmux

On a headless server you would only need to detach if you were accessing the tmux session from more than one client (and even then it is not necessary).

The easiest way to explain it is for you to start a session, detach it and restart X and then reattach with "tmux a". Then, once it is attached again, access the same session from another client (or host) and attach to it - if your consoles are a different size, you will see this http://unix.stackexchange.com/questions … the-window.

Bottom line: start it attached and detach it once it is running and you want to access it from another machine...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2011-09-19 07:07:48

netrunner
Member
Registered: 2010-04-23
Posts: 5

Re: [SOLVED] rtorrent daemon with tmux

Ok. Thank you, very informative!

Offline

Board footer

Powered by FluxBB