mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-04-19 10:47:15 +00:00
35 lines
987 B
Plaintext
Executable File
35 lines
987 B
Plaintext
Executable File
#!/usr/bin/with-contenv bashio
|
|
# ==============================================================================
|
|
# Start Watchdog service
|
|
# ==============================================================================
|
|
declare failed_count=0
|
|
declare supervisor_state
|
|
|
|
bashio::log.info "Starting local supervisor watchdog..."
|
|
|
|
while [[ failed_count -lt 2 ]];
|
|
do
|
|
sleep 300
|
|
supervisor_state="$(cat /run/supervisor)"
|
|
|
|
if [[ "${supervisor_state}" = "running" ]]; then
|
|
|
|
# Check API
|
|
if bashio::supervisor.ping > /dev/null; then
|
|
failed_count=0
|
|
else
|
|
bashio::log.warning "Maybe found an issue on API healthy"
|
|
((failed_count++))
|
|
fi
|
|
|
|
elif [[ "close stopping" = *"${supervisor_state}"* ]]; then
|
|
bashio::log.warning "Maybe found an issue on shutdown"
|
|
((failed_count++))
|
|
else
|
|
failed_count=0
|
|
fi
|
|
|
|
done
|
|
|
|
bashio::exit.nok "Watchdog detected issue with Supervisor - taking container down!"
|