-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathservice.sh
executable file
·62 lines (57 loc) · 1.44 KB
/
service.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
62
#!/usr/bin/env bash
fsroot=${FSROOT:-.}
export FSENV=${FSENV:-.local}
export PYTHONPATH=${fsroot}/lib:$PYTHONPATH
# this is needed on MacOS
export LD_LIBRARY_PATH=/usr/local/mysql/lib
RETVAL=0
case "$1" in
fiveserver)
PROG=fiveserver
TAC=${fsroot}/tac/fiveserver.tac
LOG=${fsroot}/log/fiveserver.log
PID=${fsroot}/log/fiveserver.pid
;;
sixserver)
PROG=sixserver
TAC=${fsroot}/tac/sixserver.tac
LOG=${fsroot}/log/sixserver.log
PID=${fsroot}/log/sixserver.pid
;;
*)
echo "Usage $0 {fiveserver|sixserver} {run|start|stop|status}"
RETVAL=3
exit $RETVAL
esac
case "$2" in
run)
${FSENV}/bin/twistd -noy $TAC
;;
runexec)
exec ${FSENV}/bin/twistd -noy $TAC --logfile $LOG --pidfile $PID
;;
start)
${FSENV}/bin/twistd -y $TAC --logfile $LOG --pidfile $PID
;;
stop)
cat $PID | xargs kill
;;
status)
if [ -f $PID ]; then
pid=`cat $PID`
ps $pid >/dev/null 2>&1
if [ $? = 0 ]; then
echo "$PROG ($pid) is running ..."
else
echo "$PROG is not running but pid-file exists"
RETVAL=1
fi
else
echo "$PROG is stopped"
fi
;;
*)
echo "Usage $0 {fiveserver|sixserver} {run|start|stop|status}"
RETVAL=3
esac
exit $RETVAL