• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Can start rtorrent like apache and mysql when system boot

mfaridi

Aspiring Daemon

Thanks: 14
Messages: 663

#1
I install rtorrent with rtGUI and I like rtorrent start automatically like apache and mysql when system boot and after that control it wit rtGUI.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Thanks: 5,508
Messages: 25,692

#2
Have a look if it installs a startup script in /usr/local/etc/rc.d/
If there is none you might be able to copy an existing one and modify it for use with rtorrent.
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator

Thanks: 2,493
Messages: 11,095

#4
If you want to be really lazy about it, you could try putting this in /etc/rc.local

( /usr/bin/su - username -c /usr/local/bin/rtorrent > /dev/null 2>&1 ) &

Replace 'username' with the user running rtorrent (please don't let it be root ...)

Untested, but you could try.
 

hark

Member

Thanks: 7
Messages: 25

#5
I quickly whipped up an rc script to start/stop rtorrent but rtorrent is forking, such that the PID returned by $$ is invalid. Because of this, there's no good way to either get the status of the service or to stop it, which in my mind is completely useless. (link)

There's a variety of scripts available for starting rtorrent as a service on various Linux distributions (and even the 'official' init script), and they solve this "oh god where is the PID" problem by using a named screen session. It's a massive hack, but has the added advantage of letting you reattach to the screen and manipulate rtorrent that way. I'd rather just throw rtorrent startup into rc.local, as the poster above suggests.
 

Mel_Flynn

Well-Known Member

Thanks: 77
Messages: 379

#7
Stuff that's supposed to run as a fully logged in user on reboot, use crontab(5) with the @reboot feature. This is how I start up rbot for my private IRC server.
 

p5ycho

Member

Thanks: 2
Messages: 39

#8
hark said:
I quickly whipped up an rc script to start/stop rtorrent but rtorrent is forking, such that the PID returned by $$ is invalid. Because of this, there's no good way to either get the status of the service or to stop it, which in my mind is completely useless. (link)

There's a variety of scripts available for starting rtorrent as a service on various Linux distributions (and even the 'official' init script), and they solve this "oh god where is the PID" problem by using a named screen session. It's a massive hack, but has the added advantage of letting you reattach to the screen and manipulate rtorrent that way. I'd rather just throw rtorrent startup into rc.local, as the poster above suggests.
rtorrent has a lockfile in its session dir:
Code:
root /data/incoming/torrents/session # cat rtorrent.lock
tonatiuh.p5ycho.net:+36874
maybe this can be used as pid file? it reports the current pid.
one could give rtorrent the session dir with -o session=/data/incoming/torrents/session,
Code:
cut -d + -f 2 $sessiondir/rtorrent.lock
I'm completely new to rc scripts so i could be missing something here.
If i'm missing something, please explain!
 

p5ycho

Member

Thanks: 2
Messages: 39

#9
first draw:

Code:
#!/bin/sh

# This part is needed for proper startup at boot time and proper shutdown
# PROVIDE: rtorrent
# REQUIRE: NETWORKING DEAMON
# KEYWORD: shutdown

. /etc/rc.subr

# Set daemon name and the user running the btgdaemon
name="rtorrent"
rcvar=`set_rcvar`
user="rtorrent"
sessiondir=/data/incoming/torrents/session

# pidfile, your ${user} must be able to write this file!
#rtorrent_pidfile="${sessiondir}/rtorrenttest.lock"

# Location of the rtorrent configuration
#configfile="/home/${name}/.rtorrent.rc"

start_cmd="${name}_start"
stop_cmd="${name}_stop"

# Command to execute when starting the daemon
${name}_start()
{
  su -l ${user} -c "/usr/local/bin/rtorrent -s ${sessiondir} &"
  # -l or -m?
  # -s overrides sessiondir in .rtorrent.rc
}

# Stopping the daemon (a bit of a hack)
${name}_stop()
{
  kill -9 `cut -d + -f 2 $sessiondir/rtorrent.lock`
}

load_rc_config ${name}
run_rc_command "$1"
if we want rtorrent to follow freebsd protocol, what needs to be done? patching the source to point rtorrent to a pid?