Extended watchdog

previous
Dominik Dzienia 7 months ago committed by dominik
parent e8e3575c01
commit 7a4d9ad8d0

@ -1310,9 +1310,9 @@ get_watchdog_status_code_live() {
status="crashed" status="crashed"
fi fi
regex3='MIKR.US - coś poszło nie tak' regex3='coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then if [[ "$html" =~ $regex3 ]]; then
status="restarting" status="awaiting"
fi fi
else else
@ -1321,7 +1321,7 @@ get_watchdog_status_code_live() {
else else
if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then
status="restarting" status="awaiting"
else else
status="not_running" status="not_running"
fi fi
@ -1339,9 +1339,15 @@ get_watchdog_status() {
"restart") "restart")
printf "\U1F680 wymuszono restart NS" printf "\U1F680 wymuszono restart NS"
;; ;;
"restarting") "awaiting")
printf "\U23F3 uruchamia się" printf "\U23F3 uruchamia się"
;; ;;
"restart_failed")
printf "\U1F680 restart NS to za mało"
;;
"full_restart")
printf "\U1F680 restart NS i DB"
;;
"unknown") "unknown")
printf "\U1F4A4 brak statusu" printf "\U1F4A4 brak statusu"
;; ;;
@ -2152,18 +2158,31 @@ watchdog_check() {
fi fi
if [[ "$html" =~ 'MongoDB connection failed' ]]; then if [[ "$html" =~ 'MongoDB connection failed' ]]; then
echo "Nightscout is crashed, restarting..." echo "Nightscout crash detected"
WATCHDOG_STATUS="restart" WATCHDOG_STATUS="restart"
if [ "$WATCHDOG_LAST_STATUS" == "restart_failed" ]; then
echo "Restarting DB first..."
docker restart 'ns-database'
echo "Then, restarting Nightscout..."
docker restart 'ns-server'
echo "...done"
WATCHDOG_STATUS="full_restart"
else
if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then
echo "Restarting only Nightscout..."
docker restart 'ns-server' docker restart 'ns-server'
echo "...done" echo "...done"
else
echo "Restart was tried but NS still crashed, will retry restart next time"
WATCHDOG_STATUS="restart_failed"
fi fi
fi fi
else
regex3='MIKR.US - coś poszło nie tak' regex3='coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then if [[ "$html" =~ $regex3 ]]; then
echo "Nightscout is still restarting..." echo "Nightscout is still restarting..."
WATCHDOG_STATUS="restarting" WATCHDOG_STATUS="awaiting"
fi
fi fi
if [ "$WATCHDOG_STATUS" = "detection_failed" ]; then if [ "$WATCHDOG_STATUS" = "detection_failed" ]; then
@ -2183,7 +2202,7 @@ watchdog_check() {
else else
if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then
WATCHDOG_STATUS="restarting" WATCHDOG_STATUS="awaiting"
else else
WATCHDOG_STATUS="not_running" WATCHDOG_STATUS="not_running"
fi fi

@ -1294,9 +1294,9 @@ get_watchdog_status_code_live() {
status="crashed" status="crashed"
fi fi
regex3='MIKR.US - coś poszło nie tak' regex3='coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then if [[ "$html" =~ $regex3 ]]; then
status="restarting" status="awaiting"
fi fi
else else
@ -1305,7 +1305,7 @@ get_watchdog_status_code_live() {
else else
if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then
status="restarting" status="awaiting"
else else
status="not_running" status="not_running"
fi fi
@ -1323,9 +1323,15 @@ get_watchdog_status() {
"restart") "restart")
printf "\U1F680 wymuszono restart NS" printf "\U1F680 wymuszono restart NS"
;; ;;
"restarting") "awaiting")
printf "\U23F3 uruchamia się" printf "\U23F3 uruchamia się"
;; ;;
"restart_failed")
printf "\U1F680 restart NS to za mało"
;;
"full_restart")
printf "\U1F680 restart NS i DB"
;;
"unknown") "unknown")
printf "\U1F4A4 brak statusu" printf "\U1F4A4 brak statusu"
;; ;;
@ -2136,18 +2142,31 @@ watchdog_check() {
fi fi
if [[ "$html" =~ 'MongoDB connection failed' ]]; then if [[ "$html" =~ 'MongoDB connection failed' ]]; then
echo "Nightscout is crashed, restarting..." echo "Nightscout crash detected"
WATCHDOG_STATUS="restart" WATCHDOG_STATUS="restart"
if [ "$WATCHDOG_LAST_STATUS" == "restart_failed" ]; then
echo "Restarting DB first..."
docker restart 'ns-database'
echo "Then, restarting Nightscout..."
docker restart 'ns-server'
echo "...done"
WATCHDOG_STATUS="full_restart"
else
if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then if [ "$WATCHDOG_LAST_STATUS" != "restart" ]; then
echo "Restarting only Nightscout..."
docker restart 'ns-server' docker restart 'ns-server'
echo "...done" echo "...done"
else
echo "Restart was tried but NS still crashed, will retry restart next time"
WATCHDOG_STATUS="restart_failed"
fi fi
fi fi
else
regex3='MIKR.US - coś poszło nie tak' regex3='coś poszło nie tak'
if [[ "$html" =~ $regex3 ]]; then if [[ "$html" =~ $regex3 ]]; then
echo "Nightscout is still restarting..." echo "Nightscout is still restarting..."
WATCHDOG_STATUS="restarting" WATCHDOG_STATUS="awaiting"
fi
fi fi
if [ "$WATCHDOG_STATUS" = "detection_failed" ]; then if [ "$WATCHDOG_STATUS" = "detection_failed" ]; then
@ -2167,7 +2186,7 @@ watchdog_check() {
else else
if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then if [ "$NS_STATUS" = "restarting" ] || [ "$DB_STATUS" = "restarting" ]; then
WATCHDOG_STATUS="restarting" WATCHDOG_STATUS="awaiting"
else else
WATCHDOG_STATUS="not_running" WATCHDOG_STATUS="not_running"
fi fi

@ -1 +1 @@
2024-10-06T12:43:24.897Z 2024-10-06T20:32:19.387Z
Loading…
Cancel
Save