[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

init.d shell script can't stop daemon (python script)



Hi,

this might be a little OT, but:

I wrote a (python) script that is acting like a daemon (doing something,
sleeping for 10 seconds, doing ..., sleeping ...) and would like to
launch and kill it from a shell script in /etc/init.d.

Using start-stop-daemon seemed appropriate, but the problems is that
no /var/run/$NAME.pid is written and /proc/<PID>/exe points to
/usr/bin/python. Hence stopping the daemon or preventing further deamons
from starting is not possible :(

Here's the relevant part of my init.d script:

    #! /bin/sh

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/local/sbin/printpsspoold
    NAME=printpsspoold
    DESC="printpsspool daemon"

    test -f $DAEMON || exit 0

    set -e

    case "$1" in
      start)
	    echo -n "Starting $DESC: "
	    start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DEAMON&
	    echo "$NAME."
	    ;;
      stop)
	    echo -n "Stopping $DESC: "
	    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	    echo "$NAME."
	    ;;
      .
      .
      .
    esac

    exit 0

Any hints?

TIA

Stony



Reply to: