add status API
This commit is contained in:
@@ -98,6 +98,19 @@ def http_ping(service: HTTPServiceConfig) -> None:
|
|||||||
time.sleep(cfg.pinging.rate)
|
time.sleep(cfg.pinging.rate)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/api/v1/status")
|
||||||
|
async def api_v1_up() -> dict:
|
||||||
|
rsp = {"healthy": True, "services": {}}
|
||||||
|
for name, record in uptime.items():
|
||||||
|
if record[-1] == "I":
|
||||||
|
rsp["services"][name] = {"healthy": True}
|
||||||
|
else:
|
||||||
|
rsp["services"][name] = {"healthy": False}
|
||||||
|
rsp["healthy"] = False
|
||||||
|
|
||||||
|
return rsp
|
||||||
|
|
||||||
|
|
||||||
@app.get("/", response_class=HTMLResponse)
|
@app.get("/", response_class=HTMLResponse)
|
||||||
async def root() -> str:
|
async def root() -> str:
|
||||||
template = templates.get_template("index.xht")
|
template = templates.get_template("index.xht")
|
||||||
|
|||||||
Reference in New Issue
Block a user