new version 1.1
This commit is contained in:
@@ -18,7 +18,7 @@ spec:
|
||||
- name: gitea-creds
|
||||
containers:
|
||||
- name: helloo-cicdd
|
||||
image: git.fpmoz.sum.ba/Marijanela218/helloo-cicdd:latest
|
||||
image: git.fpmoz.sum.ba/Marijanela218/helloo-cicdd:1.1
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
# ── Liveness: je li proces živ? ─────────────────
|
||||
|
||||
21
main.py
21
main.py
@@ -3,16 +3,17 @@ from fastapi import FastAPI
|
||||
import os, datetime
|
||||
|
||||
app = FastAPI()
|
||||
_healthy = True
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {
|
||||
"status": "ok",
|
||||
"version": os.getenv("APP_VERSION", "dev"),
|
||||
"timestamp": datetime.datetime.utcnow().isoformat()
|
||||
}
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"poruka": "Zdravo s k3s!", "host": os.uname().nodename}
|
||||
|
||||
if not _healthy:
|
||||
return {"status": "unhealthy"}, 503
|
||||
return {"status": "ok"}
|
||||
|
||||
@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"}
|
||||
|
||||
Reference in New Issue
Block a user