-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·85 lines (76 loc) · 1.67 KB
/
start.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
#
#
python_pidfile=./python.pid
if [ -f $python_pidfile ]
then
python_pid=`cat $python_pidfile`
fi
# Start the service node
start() {
echo "Starting python server: "
if [ -f $python_pidfile ] ; then
if test `ps -e | grep -c $python_pid` = 2; then
echo "Not starting python - instance already running with PID: $python_pid"
else
echo "Starting python"
python3 manage.py runserver 0.0.0.0:8023 &> ./python.log &
echo $! > $python_pidfile
echo "open http://localhost:8023/admin/data/recipebook/"
sleep 5
fi
else
echo "Starting python"
python3 manage.py runserver 0.0.0.0:8023 &> ./python.log &
echo $! > $python_pidfile
echo "open http://localhost:8023/admin/data/recipebook/"
sleep 5
fi
echo "node/python servers startup"
echo
}
# Restart the service node
stop() {
echo "Stopping python server: "
if [ -f $python_pidfile ] ; then
echo "stopping python"
pkill -TERM -P $python_pid
#killall python
else
echo "Cannot stop python - no Pidfile found!"
fi
echo "python server stopped"
echo
}
status() {
if [ -f $python_pidfile ] ; then
if test `ps -e | grep -c $python_pid` = 1; then
echo "python not running"
else
echo "python running with PID: [$python_pid]"
fi
else
echo "$python_pidfile does not exist! Cannot process python status!"
fi
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
sleep 5
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0