Get health status
GET /api/health/:deviceId?
Get health status for a specific device or all monitored devices
Path parameters
Optional device identifier. If omitted, returns status for all devices with automatic slot switching enabled.
Response
For a specific device:Device identifier
Currently active slot:
primary or secondaryHealth status of the primary slot
Whether the primary slot is healthy
Consecutive failure count for primary slot
ISO 8601 timestamp of last health check
Health status of the secondary slot
Whether the secondary slot is healthy
Consecutive failure count for secondary slot
ISO 8601 timestamp of last health check
Example: Get specific device health
Example: Get all devices health
Trigger manual health check
POST /api/health/check
Manually trigger health checks for all monitored devices
Response
Indicates if health checks were triggered successfully
Number of devices that were checked
Example request
Health check configuration
Environment variables
Enable or disable automatic health checks
Interval between health checks in milliseconds (default: 30 seconds)
Timeout for each health check in milliseconds (default: 5 seconds)
Example configuration
Health check process
Check execution
- Device discovery - Find devices with
autoSlotSwitch=trueand configured secondary slots - Slot testing - Run
slot-checkaction against both primary and secondary hosts - Result evaluation - Determine if each slot is healthy based on response
- Failure tracking - Increment failure counter for unhealthy slots
- Failover decision - Switch slots after 2 consecutive failures
Failover trigger
Automatic failover occurs when:- Current active slot has 2+ consecutive failures
- Alternate slot is healthy (last check succeeded)
- Device has
autoSlotSwitchenabled
Recovery
Automatic recovery occurs when:- Previously failed slot becomes healthy again
- System can switch back to preferred slot (typically primary)
- Failure counter is reset after successful checks
Monitoring scenarios
Normal operation
Primary slot degraded
Failover completed
Recovery in progress
Integration with notifications
The health check system can trigger notifications through hooks:- Slot switch notifications when failover occurs
- Alert notifications when both slots are unhealthy
- Recovery notifications when failed slots become healthy
Troubleshooting
Health checks not running
Verify environment variables:autoSlotSwitchis enabled in device configuration- Secondary slot is configured (
secondSlotHostis set) HEALTH_CHECK_ENABLED=truein environment
Frequent slot switching
If devices are switching slots too frequently:- Increase
HEALTH_CHECK_INTERVALto reduce check frequency - Increase failure threshold (currently 2 consecutive failures)
- Increase
HEALTH_CHECK_TIMEOUTif network is slow
Slots showing unhealthy incorrectly
Verify theslot-check action is configured correctly: