feat: add timestamp in health check

This commit is contained in:
2025-11-11 06:07:46 +01:00
parent b138b3114f
commit 3237bc2d70

View File

@@ -1,6 +1,6 @@
"""Blueprint for task-related routes.""" """Blueprint for task-related routes."""
import logging import logging
from datetime import datetime, date from datetime import datetime, date, timezone
from typing import Dict, Any, Tuple from typing import Dict, Any, Tuple
from flask import Blueprint, render_template, request, jsonify, Response from flask import Blueprint, render_template, request, jsonify, Response
@@ -34,13 +34,15 @@ def health_check() -> Response:
db.session.scalar(text('SELECT 1')) db.session.scalar(text('SELECT 1'))
return jsonify({ return jsonify({
'status': 'healthy', 'status': 'healthy',
'database': 'connected' 'database': 'connected',
'timestamp': datetime.now(timezone.utc).isoformat()
}), 200 }), 200
except Exception as e: except Exception as e:
logger.error(f'Health check failed: {e}') logger.error(f'Health check failed: {e}')
return jsonify({ return jsonify({
'status': 'unhealthy', 'status': 'unhealthy',
'database': 'disconnected', 'database': 'disconnected',
'timestamp': datetime.now(timezone.utc).isoformat(),
'error': str(e) 'error': str(e)
}), 503 }), 503