-
Notifications
You must be signed in to change notification settings - Fork 105
/
run.sh
executable file
·49 lines (41 loc) · 905 Bytes
/
run.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
#!/bin/bash
APP_PATH=`dirname $0`
cd ${APP_PATH}
DB=/data/db
option=$1
[ -z "$option" ] && option=start
start(){
nohup mongod --port 27017 --dbpath=${DB} --auth > ${APP_PATH}/logs/db.log &
nohup python ./InsectsAwake.py > ${APP_PATH}/logs/log.log &
}
stop(){
python_manage=`ps -ef | grep "InsectsAwake.py" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
for pid in ${python_manage}
do
kill -9 ${pid}
done
mongo_pid=`ps -ef | grep "mongod" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
for pid in ${mongo_pid}
do
kill -9 ${pid}
done
}
case ${option} in
start)
echo "Starting Now......"
start
echo "Starting Finished"
;;
stop)
echo "Stopping Now......"
stop
echo "Stopping Finished"
;;
restart)
echo "Restart Now......"
stop
start
echo "Restart Finished"
;;
*)
esac