downgrade to v3
This commit is contained in:
23
main.py
23
main.py
@@ -1,17 +1,22 @@
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
import os, datetime
|
import os
|
||||||
|
|
||||||
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.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"}
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
def root():
|
def read_root():
|
||||||
return {"poruka": "Zdravo s k3s!", "host": os.uname().nodename}
|
return {"poruka": "Hello iz mog Docker containera!"}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user