Can start rtorrent like apache and mysql when system boot

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.
 
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.
 
If you want to be really lazy about it, you could try putting this in [font="System"]/etc/rc.local[/font]

[font="System"]( /usr/bin/su - username -c /usr/local/bin/rtorrent > /dev/null 2>&1 ) &[/font]

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

Untested, but you could try.
 
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.
 
Any sane person runs rtorrent in screen anyway, so I guess adding that to the rc.local could work, though I believe screen isn't a fan of running in a su'ed environment.
 
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.
 
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!
 
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?
 
Back
Top