-
Notifications
You must be signed in to change notification settings - Fork 1
/
do.sh
executable file
·120 lines (109 loc) · 2.44 KB
/
do.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
function startworker {
echo "start hawk worker..."
celery multi start 5 -A hawk -l info --pidfile=./logs/%n.pid --logfile=./logs/%n%I.log
}
function stopworker {
echo "stop hawk worker..."
celery multi stopwait 5 -A hawk -l info --pidfile=./logs/%n.pid
}
function restartworker {
echo "restart hawk worker..."
celery multi restart 5 -A hawk -l info --pidfile=./logs/%n.pid --logfile=./logs/%n%I.log
}
function startflower {
echo "start flower server..."
celery -A hawk flower --port=5555 &
}
function stopflower {
echo "stop flower server..."
python ./cli/killflower.py
}
function startweb {
echo "start web server..."
sudo python app.py --port=80 &
}
function usage {
echo "usage:"
echo " start: start hawk worker"
echo " stop: stop hawk worker"
echo " restart: restart hawk worker"
echo " startd: start dispatch worker"
echo " stopd: stop dispatch worker"
echo " restartd: restart dispatch worker"
echo " startall: start all worker"
echo " restartall: restart all worker"
echo " stop all: stop all worker"
echo " flower: start flower server"
echo " web: start web server"
echo " status: use ps show status"
echo " clearlog: clear all log"
}
function startd {
echo "start dispatch worker..."
python dispatch.py start
}
function restartd {
echo "restart dispatch worker..."
python dispatch.py restart
}
function stopd {
echo "stop dispatch worker..."
python dispatch.py stop
}
action=$1
case $action in
start)
startworker
;;
stop)
stopworker
;;
restart)
restartworker
;;
flower)
startflower
;;
web)
startweb
;;
startd)
startd
;;
restartd)
restartd
;;
stopd)
stopd
;;
status)
python ./cli/status.py
# service redis status
;;
startall)
startworker
startd
startflower
;;
stopall)
stopd
stopworker
stopflower
;;
reall)
restartworker
restartd
stopflower
startflower
;;
clearlog)
rm -f ./logs/*.log
;;
dump)
# mysqldump -uroot -p hawk > /home/hawk/backup/$(date +'%Y_%m_%d').sql
;;
*)
usage
;;
esac