forked from whatvn/py-balancer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runserver
executable file
·53 lines (41 loc) · 920 Bytes
/
runserver
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
#!/usr/bin/env bash
# Start httpserver daemon
APP_NAME="httpserver"
PYTHON="/usr/bin/python"
DAEMON="/usr/local/py-balancer"
PID_FILE="${DAEMON}/logs/${APP_NAME}.pid"
[ ! -d $DAEMON ] && printf "Program is not exist\n" && exit 2
cd $DAEMON
ARGS="${DAEMON}/${APP_NAME} --port 2000 --maxt-thread=2000"
function _start() {
printf "Starting $APP_NAME...."
start-stop-daemon --start --background --quiet --make-pidfile --pidfile $PID_FILE --exec $PYTHON -- $ARGS
sleep 1
printf "Done.\n"
}
function _stop() {
printf "Stopping $APP_NAME...."
start-stop-daemon --stop --quiet --pidfile $PID_FILE
if [ "$?" -eq "0" ]; then
printf "Done.\n"
fi
}
function _restart() {
_stop
sleep 1
_start
}
case "$1" in
start)
_start
;;
stop)
_stop
;;
restart)
_restart
;;
*)
printf "Usage: $0 start|stop|restart\n"
;;
esac