File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ function get_target_process(){
4+ proc_name=$1
5+ pids=` ps -ef | grep " $proc_name " | grep -v grep | awk ' {print $2}' `
6+ echo $pids
7+ }
8+
9+ function check_target_process_exist() {
10+ proc_name=$1
11+ pids=$( get_target_process " $proc_name " )
12+ ret=" "
13+ if [ ! -n " $pids " ]; then
14+ ret=" false"
15+ else
16+ ret=" true"
17+ fi
18+ echo " $ret "
19+ }
20+
21+ function ping_celery() {
22+ celery -A codedog inspect ping -d celery@$HOSTNAME 2>&1 > /dev/null
23+ echo $?
24+ }
25+
26+ function check_celery_healthy() {
27+ result=0
28+ for(( i= 1 ;i<= 3 ;i++ )) ; do
29+ result=` ping_celery`
30+ echo " check celery result: $result "
31+ if [ " $result " == " 0" ]; then
32+ break
33+ fi
34+ sleep 10
35+ done
36+
37+ if [ " $result " != " 0" ]; then
38+ pids=` get_target_process ' celery -A codedog' `
39+ kill -HUP $pids
40+ fi
41+ }
42+
43+ check_celery_healthy
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ function get_target_process(){
4+ proc_name=$1
5+ pids=` ps -ef | grep " $proc_name " | grep -v grep | awk ' {print $2}' `
6+ echo $pids
7+ }
8+
9+ function check_target_process_exist() {
10+ proc_name=$1
11+ pids=$( get_target_process " $proc_name " )
12+ ret=" "
13+ if [ ! -n " $pids " ]; then
14+ ret=" false"
15+ else
16+ ret=" true"
17+ fi
18+ echo " $ret "
19+ }
20+
21+ function ping_celery() {
22+ celery -A codedog inspect ping -d celery@$HOSTNAME 2>&1 > /dev/null
23+ echo $?
24+ }
25+
26+ function check_celery_healthy() {
27+ result=0
28+ for(( i= 1 ;i<= 3 ;i++ )) ; do
29+ result=` ping_celery`
30+ echo " check celery result: $result "
31+ if [ " $result " == " 0" ]; then
32+ break
33+ fi
34+ sleep 10
35+ done
36+
37+ if [ " $result " != " 0" ]; then
38+ pids=` get_target_process ' celery -A codedog' `
39+ kill -HUP $pids
40+ fi
41+ }
42+
43+ check_celery_healthy
You can’t perform that action at this time.
0 commit comments