1

I'm trying to run my python script as a service... But I'm getting this error when I call sudo update-rc.d mylistener start:

Use of uninitialized value $ARGV[1] in pattern match (m//) at /usr/sbin/update-rc.d line 192.

update-rc.d: error: expected NN after start

Here is my init script mylistener:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          mylistener
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: This is the description.
# Description:       This is the description.
### END INIT INFO

DAEMON=/srv/example.org/public/env/bin/python
ARGS=/srv/example.org/public/my_listener.py
PIDFILE=/srv/example.org/my_listener.pid

case "$1" in
  start)
    echo "starting server"
    /sbin/start-stop-daemon --start --pidfile $PIDFILE \
        --user www-data --group www-data \
        -b --make-pidfile \
        --chuid www-data \
        --exec $DAEMON $ARGS
    ;;
  stop)
    echo "stopping server"
    /sbin/start-stop-daemon --stop --pidfile $PIDFILE --verbose
    ;;
  *)
    echo "Useage: /etc/init.d/mylistener {start|stop}"
    exit 1
    ;;
esac

exit 0

Can anyone see where I'm going wrong? This is running on a debian server.

0

1 Answer 1

4

Try this:

sudo update-rc.d mylistener start 20 2 3 4 5 . stop 80 0 1 6 .

it means that your init script will be start at 20th order, runlevel 2345 and stop at 80th priority, runlevel 016.

or simple is:

sudo update-rc.d mylistener defaults
8
  • If I run sudo update-rc.d mylistener start 20 3 5 . I get Adding system startup for /etc/init.d/mylistener but I cannot see where it's running and it doesn't appear to run either.
    – ingh.am
    Oct 25, 2011 at 10:53
  • What happen if you run /etc/init.d/mylistener start and verify it is running with ps -ef | grep mylistener?
    – quanta
    Oct 25, 2011 at 10:57
  • james 27380 20728 0 12:00 pts/1 00:00:00 grep mylistener
    – ingh.am
    Oct 25, 2011 at 11:01
  • Ah thanks, it's working now :) I must have not tried starting it like that!
    – ingh.am
    Oct 25, 2011 at 11:05
  • 1
    update-rc.d mylistener defaults is already make your script run at boot time. Read the manual man update-rc.d.
    – quanta
    Oct 28, 2011 at 0:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .