From fe26dc1bcf8c3211de7778061d862d5a307509e1 Mon Sep 17 00:00:00 2001 From: ITO Mac Date: Mon, 4 May 2026 18:22:49 +0200 Subject: [PATCH] . --- app/main.py | 124 +++++----------------------------------------------- 1 file changed, 11 insertions(+), 113 deletions(-) diff --git a/app/main.py b/app/main.py index 634e363..3f39a2b 100644 --- a/app/main.py +++ b/app/main.py @@ -1,123 +1,21 @@ import os -import datetime +import signal from fastapi import FastAPI -from fastapi.responses import HTMLResponse -app = FastAPI(title="Distribuirani Sustavi - FPMOZ") - -SERVICE_NAME = os.getenv("SERVICE_NAME", "distribuirani-service") -LOG_LEVEL = os.getenv("LOG_LEVEL", "info") -WELCOME_MSG = os.getenv("WELCOME_MSG", "Pozdrav iz FPMOZ k3s clustera!") - - -@app.get("/", response_class=HTMLResponse) -def root(): - return f""" - - - - - {SERVICE_NAME} - - - -
-

Distribuirani Sustavi

-

{WELCOME_MSG}

-
-
- Servis - {SERVICE_NAME} -
-
- Hostname - {os.getenv("HOSTNAME", "local")} -
-
- Log Level - {LOG_LEVEL} -
-
- Vrijeme - {datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")} -
-
- FPMOZ K3s Cluster • GitOps CI/CD -
- -""" +app = FastAPI() +_healthy = True @app.get("/health") def health(): + if not _healthy: + return {"status": "unhealthy"}, 503 return {"status": "ok"} -@app.get("/info") -def info(): - return { - "service": SERVICE_NAME, - "hostname": os.getenv("HOSTNAME", "local"), - "log_level": LOG_LEVEL, - "welcome": WELCOME_MSG, - "timestamp": datetime.datetime.now(datetime.timezone.utc).isoformat(), - } \ No newline at end of file +@app.post("/break") +def break_health(): + """Simulira pad servisa za testiranje liveness probe-a""" + global _healthy + _healthy = False + return {"message": "Servis je sada nezdrav — ocekuj restart"}