2022-05-06 06:15:56 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
healthy=true
|
|
|
|
|
while read -r line
|
|
|
|
|
do
|
|
|
|
|
line_arr=($line)
|
|
|
|
|
process=${line_arr[0]}
|
|
|
|
|
status=${line_arr[1]}
|
|
|
|
|
if [ $status != "RUNNING" ]; then
|
|
|
|
|
healthy=false
|
|
|
|
|
echo "ERROR:- PROCESS: $process - STATUS: $status"
|
|
|
|
|
else
|
|
|
|
|
echo "PROCESS: $process - STATUS: $status"
|
|
|
|
|
if [[ "$process" == 'editor' ]]; then
|
2022-05-27 11:35:21 +00:00
|
|
|
if [[ $(curl -Lfk -s -w "%{http_code}\n" http://localhost/ -o /dev/null) -ne 200 ]]; then
|
|
|
|
|
echo 'ERROR: Editor is down';
|
|
|
|
|
healthy=false
|
2022-05-06 06:15:56 +00:00
|
|
|
fi
|
|
|
|
|
elif [[ "$process" == "server" ]]; then
|
2023-08-01 04:28:49 +00:00
|
|
|
if [[ $(curl -s -w "%{http_code}\n" http://localhost:8080/api/v1/health -o /dev/null) -ne 200 ]]; then
|
2022-05-06 06:15:56 +00:00
|
|
|
echo 'ERROR: Server is down';
|
|
|
|
|
healthy=false
|
|
|
|
|
fi
|
|
|
|
|
elif [[ "$process" == "rts" ]]; then
|
|
|
|
|
if [[ $(curl -s -w "%{http_code}\n" http://localhost:8091/ -o /dev/null) -ne 302 ]]; then
|
|
|
|
|
echo 'ERROR: RTS is down';
|
|
|
|
|
healthy=false
|
|
|
|
|
fi
|
|
|
|
|
elif [[ "$process" == "mongo" ]]; then
|
|
|
|
|
if [[ $(mongo --eval 'db.runCommand("ping").ok') -ne 1 ]]; then
|
|
|
|
|
echo 'ERROR: Mongo is down';
|
|
|
|
|
healthy=false
|
|
|
|
|
fi
|
|
|
|
|
elif [[ "$process" == "redis" ]]; then
|
|
|
|
|
if [[ $(redis-cli ping) != 'PONG' ]]; then
|
|
|
|
|
echo 'ERROR: Redis is down';
|
|
|
|
|
healthy=false
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done <<< $(supervisorctl status all)
|
|
|
|
|
if [ $healthy == true ]; then
|
|
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
exit 1
|
2023-08-01 04:28:49 +00:00
|
|
|
fi
|