forked from Ostaer/FlexGW
-
Notifications
You must be signed in to change notification settings - Fork 2
/
website_console
executable file
·94 lines (86 loc) · 1.88 KB
/
website_console
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
#########################################################################
# chkconfig: - 96 48
# description: this is script can start/stop/restart website
#########################################################################
script_home="/usr/local/flexgw"
website_prog="/usr/local/flexgw/python/bin/gunicorn"
website_gunicorn_etc="$script_home/gunicorn.py"
website_app="website:app"
website_pid="$script_home/website.pid"
status()
{
if [ -f $website_pid ]; then
website_pid=$(cat $website_pid)
else
echo $"not found website pid file, seems not running?"
return 2
fi
if (kill -0 $website_pid > /dev/null 2>&1); then
echo $"website is running"
return 0
else
echo $"website is not running"
return 1
fi
}
reload()
{
status
if [ $? -eq 0 ]; then
kill -s SIGHUP $website_pid
if [ $? -eq 0 ]; then
echo $"website reload ok"
else
echo $"website reload failed"
fi
fi
}
stop()
{
status
if [ $? -eq 0 ]; then
kill -s SIGTERM $website_pid
if [ $? -eq 0 ]; then
echo $"website stop ok"
else
echo $"website stop failed"
fi
sleep 2
status
fi
}
start()
{
status
if [ $? -ne 0 ]; then
echo $"starting website..."
[ -f /usr/local/flexgw/instance/snat-rules.iptables ] &&
iptables-restore --table=nat < /usr/local/flexgw/instance/snat-rules.iptables
$website_prog -D -c $website_gunicorn_etc $website_app --pythonpath $script_home
sleep 2
status
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit $?