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