Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

After moving to new baselayout2 in gentoo I always have

 rtorrentd                               [  crashed  ]

even though it runs in screen with no issues.

Here are the conf.d:

# Owner of screen session and rtorrent process
USER="zerkms"

# Home dir with .rtorrent.rc
HOME_DIR="/home/zerkms"

# Screen options for starting rtorrent
SCREEN_OPTS="-dmS rtorrent /usr/bin/rtorrent"

# Path to *.pid file
PIDFILE="/var/run/screen.pid"

# Path to 'screen' binary
SCREEN_BIN="/usr/bin/screen"

# Path to 'rtorrent' binary
RTORRENT_BIN="/usr/bin/rtorrent"

and init.d accordingly:

depend() {
        need net
}

start() {
        ebegin "Starting screen & rtorrent"
        env HOME=${HOME_DIR} start-stop-daemon --start --background --make-pidfile --pidfile ${PIDFILE} \
        --chuid ${USER} --exec ${SCREEN_BIN} -- ${SCREEN_OPTS}
        eend $?
}

stop() {
        ebegin "Stopping screen & rtorrent"
        start-stop-daemon --stop --quiet --exec ${RTORRENT_BIN}
        eend $?
}

restart() {
        ebegin "Restarting screen & rtorrent"
        svc_stop
        sleep 2
        svc_start
        eend $?
}

Tried to compare with any valid init.d script but haven't found any significant differences. Any ideas why that [crached] label appears?

share|improve this question
    
Do you want to know what outputs the text, or what would tell it that the daemon has crashed? –  Ignacio Vazquez-Abrams May 9 '11 at 14:41
    
@Ignacio Vazquez-Abrams: I would like to know why it thinks that daemon has crashed (because actually it is not) and want to fix it to be [started] like other daemons –  zerkms May 9 '11 at 14:44

1 Answer 1

up vote 2 down vote accepted

The normal way to detect that a daemon has crashed is presence of a PID file, but absence of a daemon process with that PID. The daemon removes the PID file during normal shutdown, but leaves it after a crash.

If you believe that the detection is faulty then you should shut down the daemon, erase the PID file, then restart the daemon.

share|improve this answer
    
Did that. After restart it is 13351 in pidfile, but the main process runs with 13354. Hm. Why did it detect pid wrongly on start? –  zerkms May 9 '11 at 14:53
    
It might be that the process double-forks in order to daemonize, and this is confusing start-stop-daemon. See if the daemon itself provides a pidfile mechanism. –  Ignacio Vazquez-Abrams May 9 '11 at 14:54
    
what daemon? It is just a screen –  zerkms May 9 '11 at 14:56
    
Okay, then that's definitely confusing it, since screen and the main process would (must) have different PIDs. –  Ignacio Vazquez-Abrams May 9 '11 at 14:57
    
well, changed -dmS part of conf.d to -DmS and it helped. Found at bugs.gentoo.org/show_bug.cgi?id=303641. Thanks for your time. –  zerkms May 9 '11 at 15:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.