-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcheck_init_works.sh
More file actions
executable file
·78 lines (61 loc) · 1.48 KB
/
check_init_works.sh
File metadata and controls
executable file
·78 lines (61 loc) · 1.48 KB
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
#!/usr/bin/env bash
check_health() { # arg should be port
url="http://127.0.0.1:$1/health_check.html"
if curl -s $url | grep OK; then
return 0
else
return 1
fi
}
check_running() { # arg should be role
echo `ps -ef |grep $1 |awk '/$product/ && !/awk/ {print $2}'`
}
# yadda yadda
status=0
# does stop work?
backend_ports=`$serverinfo backend-ports`
$script stop > /dev/null 2>&1
sleep 60 # stop is slow
for i in `check_running be`; do
echo "ERROR: $product is still running on pid $i after stop!"
status=1
done
# can we curl the stats page?
for i in $backend_ports; do
health=`check_health $i`
if [ "$health" -ne 1 ]; then
echo "ERROR: $product is still responding to port $i"
status=1
fi
done
# does start work?
$script start > /dev/null 2>&1
sleep 60
pids_starttest=`check_running be`
if [ -z "$pids_starttest" ]
echo "ERROR: $product is not running after start!"
status=1
fi
for i in $backend_ports; do
health=`check_health $i`
if [ "$health" -ne 0 ]; then
echo "ERROR: $product is not responding on port $i"
status=1
fi
done
# does restart work?
$script restart > /dev/null 2>&1
sleep 120
pids_restarttest=`check_running be`
if [ "$pids_restarttest" -eq "$pids_starttest" ]; then
echo "ERROR: sailfish did not restart!"
status=1
fi
for i in $backend_ports; do
health=`check_health $i`
if [ "$health" -ne 0 ]; then
echo "ERROR: $product is not responding to healthcheck on $i after restart"
status=1
fi
done
exit $status