I am using a start-stop-daemon to make a INIT script for my script. I am using `--make-pidfile` cause my script doesnt make its own pid. I can start my script using start and pid file generates with appropriate PID. But the stop function doesnt work. I am getting return code 0 with `--oknodo` and 1 without it. If I do
ps -ef | grep perl
and
cat /home/me/mydaemon/run
I always see the same PID. I can terminate the script using
kill -15 PID.
But not with the stop function of my init script.
Whats the proper way to stop my process?
As per start-stop-daemon manual,
Quote:
--stop Checks for the existence of a specified process. If such a process exists, start-stop-daemon sends it the signal specified by --signal, and exits with error status 0. If such a process does not exist, start-stop-daemon exits with error status 1 (0 if --oknodo is specified). If --retry is specified, then start-stop-daemon will check that the process(es) have terminated.
|
I didnt find find any documentation for `--signal` itself. Like how to specify `--signal` if I want to send a SIGTERM.
Code:
#!/bin/sh
### BEGIN INIT INFO
# Provides: myd
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Diitalk daemon for sending push notifications
### END INIT INFO
. /lib/lsb/init-functions
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON="/home/me/mydaemon/myd"
NAME="myd"
DESC="My Daemon"
HOMEDIR=/home/me/mydaemon/run
PIDFILE="$HOMEDIR/$NAME.pid"
USER=me
GROUP=me
SHM_MEMORY=64
PKG_MEMORY=8
DUMP_CORE=no
case "$1" in
start|debug)
log_daemon_msg "Starting $DESC: $NAME"
start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE \
--exec $DAEMON || log_failure_msg " already running"
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping $DESC: $NAME"
start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
--exec $DAEMON
echo $?
log_end_msg 0
;;