feat(backend): add /api/health endpoint for k8s readiness probe
This commit is contained in:
parent
0a58373d86
commit
3da4cfd306
@ -105,6 +105,20 @@ def delete_task(task_id):
|
||||
return jsonify({"result": "ok"})
|
||||
|
||||
|
||||
@app.route("/api/health", methods=["GET"])
|
||||
def health():
|
||||
try:
|
||||
conn = get_db()
|
||||
cur = conn.cursor()
|
||||
cur.execute("SELECT 1")
|
||||
cur.fetchone()
|
||||
cur.close()
|
||||
conn.close()
|
||||
return jsonify({"status": "ok"}), 200
|
||||
except Exception as exc:
|
||||
return jsonify({"status": "unhealthy", "error": str(exc)}), 503
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
init_db()
|
||||
app.run(host="0.0.0.0", port=5000)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user