This commit is contained in:
parent
da13db921f
commit
618a139847
24
app.py
24
app.py
@ -135,12 +135,30 @@ def health():
|
|||||||
def ready():
|
def ready():
|
||||||
"""GET /ready - Kubernetes readiness probe"""
|
"""GET /ready - Kubernetes readiness probe"""
|
||||||
try:
|
try:
|
||||||
# Try to access the status file
|
# Check if data directory is writable
|
||||||
if os.path.exists(STATUS_FILE):
|
data_dir = os.path.dirname(STATUS_FILE)
|
||||||
|
if not os.path.exists(data_dir):
|
||||||
|
os.makedirs(data_dir, exist_ok=True)
|
||||||
|
|
||||||
|
# Try to read or create status file
|
||||||
|
if not os.path.exists(STATUS_FILE):
|
||||||
|
# File doesn't exist yet, try to create it
|
||||||
|
default_status = {
|
||||||
|
"repo": "unknown",
|
||||||
|
"server": "unknown",
|
||||||
|
"sync_status": "UNKNOWN",
|
||||||
|
"drift_count": 0,
|
||||||
|
"files": [],
|
||||||
|
"last_check": ""
|
||||||
|
}
|
||||||
|
save_status(default_status)
|
||||||
|
|
||||||
|
# Verify we can read it
|
||||||
status = load_status()
|
status = load_status()
|
||||||
if isinstance(status, dict):
|
if isinstance(status, dict):
|
||||||
return jsonify({"status": "ready"}), 200
|
return jsonify({"status": "ready"}), 200
|
||||||
return jsonify({"status": "not_ready", "reason": "status file not accessible"}), 503
|
|
||||||
|
return jsonify({"status": "not_ready", "reason": "invalid status data"}), 503
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Readiness check failed: {e}")
|
logger.error(f"Readiness check failed: {e}")
|
||||||
return jsonify({"status": "not_ready", "error": str(e)}), 503
|
return jsonify({"status": "not_ready", "error": str(e)}), 503
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user