forked from oceanobservatories/stream_engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage-streamng
executable file
·68 lines (61 loc) · 1.49 KB
/
manage-streamng
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
63
64
65
66
67
68
#!/bin/bash
HERE=$(cd $(dirname $(readlink -f $BASH_SOURCE)) && pwd)
PIDFILE="$HERE/stream_engine.pid"
NAME="Stream Engine"
timestamp=`date +%F-%H-%M-%S`
start(){
echo "Starting $NAME..."
if [ -f $PIDFILE ]; then
# PIDFILE exists, but the corresponding process does not
if [ ! -f /proc/$(cat $PIDFILE)/status ]; then
rm $PIDFILE
fi
fi
if [ ! -f $PIDFILE ]; then
export OOI_GUNICORN_LOG_LOC=$HERE
gunicorn --chdir $HERE --pythonpath $HERE --log-config $HERE/logging.conf --daemon -p $PIDFILE --config $HERE/gunicorn_config.py engine.routes:app
else
echo "$NAME: Trying to start stream engine, but pid exists"
fi
}
stop(){
echo "Stopping $NAME..."
if [ -f $PIDFILE ]; then
kill $(<$PIDFILE)
rm $PIDFILE
else
echo "$NAME: Trying to stop stream engine, but pid does not exist"
rm $PIDFILE
fi
}
reload(){
echo "Reloading $NAME..."
if [ -f $PIDFILE ]; then
kill -HUP $(<$PIDFILE)
rm $PIDFILE
else
echo "$NAME: Trying to reload stream engine, but pid does not exist"
rm $PIDFILE
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
[ -f $PIDFILE ] && echo "$NAME: "$(<$PIDFILE) || echo "$NAME:"
;;
*)
echo "Usage: manage-streamng (start|stop|reload|restart|status)"
;;
esac