-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
spawn_fcgi_debian.sh
executable file
·61 lines (53 loc) · 1.36 KB
/
spawn_fcgi_debian.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
#culled from lighttpd init script
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=$2
NAME=spawn-fcgi
DESC="$NAME"
TEMPDIR=$5
FCGI=qgis_mapserv
PIDFILE=$TEMPDIR/var/$NAME.pid
FCGISOCKET=$3
FCGIBIN=$4
SCRIPTNAME=$NAME
test -x $DAEMON || exit 1
set -e
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting $DESC" $NAME
if ! start-stop-daemon --start --oknodo --quiet \
--pidfile $PIDFILE -m -b --exec $DAEMON -- \
-n -C 0 -s $FCGISOCKET -f $FCGIBIN
then
log_end_msg 1
else
log_end_msg 0
fi
;;
stop)
log_daemon_msg "Stopping $DESC" $NAME
# this would also kill any other qgis_mapserv.fcgi running; not good
#if killall --signal 2 $FCGI.fcgi > /dev/null 2> /dev/null
# we can get around this because there should only be 1 process when testing
if kill -s 9 $(cat $PIDFILE) > /dev/null 2> /dev/null
then
rm -f $PIDFILE $FCGISOCKET
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
$0 stop $2 $3 $4 $5
$0 start $2 $3 $4 $5
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" spawn-fcgi && exit 0 || exit $?
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0