Add complete health check implementation for Docker HEALTHCHECK and Traefik health routing with: Response fields: - status: "ok" or "degraded" - uptime_s: seconds since mothership boot - version: mothership version string - nodes_online: count of connected nodes - db: "ok" or "failing" (SELECT 1 with 100ms timeout) - load_level: 0-3 from load shedding state - reason: human-readable explanation (only when degraded) HTTP status codes: - 200 for healthy (status="ok") - 503 for degraded (status="degraded") Degraded conditions: - Database unreachable - Load level 3 sustained for >60 seconds - No nodes connected after 5 minutes uptime Docker HEALTHCHECK updated to verify status="ok" response. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1 KiB
C
53 lines
1 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "esp_err.h"
|
|
|
|
/**
|
|
* Initialize NTP client.
|
|
* Sets up SNTP service with default configuration.
|
|
*/
|
|
esp_err_t ntp_init(void);
|
|
|
|
/**
|
|
* Set NTP server and start synchronization.
|
|
* Call this after WiFi connects.
|
|
*
|
|
* @param ntp_server NTP server hostname (e.g., "pool.ntp.org")
|
|
* @return ESP_OK on success
|
|
*/
|
|
esp_err_t ntp_start_sync(const char *ntp_server);
|
|
|
|
/**
|
|
* Wait for NTP synchronization to complete.
|
|
*
|
|
* @param timeout_ms Maximum time to wait in milliseconds
|
|
* @return true if sync succeeded, false if timeout
|
|
*/
|
|
bool ntp_wait_sync(int timeout_ms);
|
|
|
|
/**
|
|
* Check if NTP is synchronized.
|
|
*
|
|
* @return true if synchronized, false otherwise
|
|
*/
|
|
bool ntp_is_synced(void);
|
|
|
|
/**
|
|
* Get current NTP sync status as a string.
|
|
*
|
|
* @return "synced" or "unsynced"
|
|
*/
|
|
const char* ntp_status_str(void);
|
|
|
|
/**
|
|
* Start periodic NTP resync timer.
|
|
* Resyncs every 10 minutes by default.
|
|
*/
|
|
void ntp_start_periodic_resync(void);
|
|
|
|
/**
|
|
* Stop NTP and cleanup resources.
|
|
*/
|
|
void ntp_stop(void);
|