forked from hanbinggary/options_monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_monitor.sh
executable file
·67 lines (63 loc) · 1.38 KB
/
start_monitor.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
#!/bin/bash
SERVICE_NAME=options_monitor
PID=$SERVICE_NAME.pid
ProcNumber=`ps -ef | grep -w $SERVICE_NAME | grep -v grep | wc -l`
pyimm=
imm=
pypush=
push=
pyrecalc_siv=
recalc_siv=
pyscp=
scp=
while getopts "m:iprc" opt; do
case ${opt} in
m)
mode=$OPTARG
;;
i)
pyimm='--imm=True'
imm='-i'
;;
p)
pypush='--push=True'
push='-p'
;;
r)
pyrecalc_siv='--recalculate_siv=True'
recalc_siv='-r'
;;
c)
pyscp='--scp=True'
scp='-c'
;;
*)
echo 'unknown argument. '
esac
done
case "$mode" in
start)
if [ -f ./$PID ]; then
echo "$SERVICE_NAME is started, please use the restart option. "
else
nohup python3 ./options_monitor.py $pyimm $pypush $pyrecalc_siv $pyscp 2>&1 &
echo $! > ./$PID
echo "==== start $SERVICE_NAME ===="
fi
;;
stop)
kill -9 `cat ./$PID`
rm -rf ./$PID
echo "==== stop $SERVICE_NAME ===="
;;
restart)
$0 -m stop
sleep 2
$0 -m start $imm $push $recalc_siv $scp
;;
*)
echo "Usage: bash start_monitor.sh -m [start|stop|restart]"
echo `python3 ./options_monitor.py --help`
;;
esac
exit 0