forked from hacksman/spider_world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_supervisor.sh
executable file
·63 lines (49 loc) · 1.16 KB
/
run_supervisor.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
#!/usr/bin/env bash
CONFIG=spder_supervisord.conf
start() {
status
if [ ! $? -eq 0 ]; then
echo "process is already running.."
return 1
fi
mkdir -p logs
pip install --user supervisor -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com
# 启动后台程序
supervisord -c ${CONFIG}
echo "process start success..."
}
stop() {
ps -ef | grep -v grep | grep supervisord | grep -w ${CONFIG} | awk '{print $2}' | xargs kill -9
# 先关闭监控脚本
ret=`ps -ef | grep -v grep | grep -w lanuch_cp_spider.py | awk '{print $2}'`
if [ -z "${ret}" ]; then
echo "lanuch_cp_spider.py not running.."
else
kill -9 ${ret}
fi
echo "process stop success..." && return 1
}
restart() {
stop
sleep 1
start
}
status() {
result=1
pid=`ps -ef | grep -v grep | grep supervisord | grep -w ${CONFIG} | awk '{print $2}'`
if [ -z "${pid}" ]; then
echo "后台管理服务不存在..."
result=0
else
echo "supervisord ${pid}"
fi
return ${result}
}
case "$1" in
start|stop|restart|status)
$1
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac