diff --git a/CHANGELOG.md b/CHANGELOG.md index 066ba618..9d46a7a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ compatibility changes and a short test procedure. These changes are not yet a ta a run by up to ~150 MB on small devices without changing the plan. - Optional `general.timezone_override`: an IANA timezone name used as `general.timezone` instead of the lookup from latitude/longitude. Unset (default), the lookup is unchanged. +- `GET /v1/health` reports `started_at`, the start time of the server process, so a client + notices a restart also in a container (where the pid is always 1). - New PV forecast providers giving operators more cloud forecast sources to choose from in addition to Akkudoktor, VRM and Import: - `PVForecastPVNode` — native 15-minute forecasts from the pvnode.com API. diff --git a/src/akkudoktoreos/server/eos.py b/src/akkudoktoreos/server/eos.py index f64caf71..dd749164 100755 --- a/src/akkudoktoreos/server/eos.py +++ b/src/akkudoktoreos/server/eos.py @@ -489,6 +489,12 @@ async def fastapi_admin_server_shutdown_post() -> dict: } +# Start of this server process. A client that pushes data to EOS (forecasts, +# configuration) has to notice a restart and push again. The pid cannot tell: +# in a container the server is always pid 1. +SERVER_STARTED_AT = to_datetime(as_string=True) + + @app.get("/v1/health", tags=["health"]) def fastapi_health_get(): # type: ignore """Health check endpoint to verify that the EOS server is alive.""" @@ -496,6 +502,7 @@ def fastapi_health_get(): # type: ignore { "status": "alive", "pid": psutil.Process().pid, + "started_at": SERVER_STARTED_AT, "version": __version__, "energy-management": { "start_datetime": to_datetime(get_ems().start_datetime, as_string=True),