fix health endpoints
This commit is contained in:
32
app/main.py
32
app/main.py
@@ -1,19 +1,43 @@
|
||||
from fastapi import FastAPI
|
||||
import platform
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
_healthy = True
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def root():
|
||||
return {"poruka": "Hello iz mog Docker containera v2!"}
|
||||
|
||||
|
||||
|
||||
@app.get("/info")
|
||||
def info():
|
||||
return {
|
||||
"python": platform.python_version(),
|
||||
"verzija": "2.0"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
@app.get("/live")
|
||||
def live():
|
||||
return {"status": "alive"}
|
||||
|
||||
|
||||
@app.get("/ready")
|
||||
def ready():
|
||||
if not _healthy:
|
||||
return {"status": "not ready"}
|
||||
return {"status": "ready"}
|
||||
|
||||
|
||||
@app.post("/break")
|
||||
def break_health():
|
||||
global _healthy
|
||||
_healthy = False
|
||||
return {"message": "Simuliran pad servisa (readiness će pasti)"}
|
||||
Reference in New Issue
Block a user