better health check
This commit is contained in:
9
app.py
9
app.py
@@ -13,6 +13,7 @@ import click
|
||||
from utils import timeago
|
||||
from extensions import db, login_manager, csrf
|
||||
from utils.email_templates import create_default_templates
|
||||
from datetime import datetime
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
@@ -58,14 +59,18 @@ def create_app():
|
||||
try:
|
||||
# Check database connection
|
||||
db.session.execute('SELECT 1')
|
||||
db.session.commit()
|
||||
return jsonify({
|
||||
'status': 'healthy',
|
||||
'database': 'connected'
|
||||
'database': 'connected',
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
}), 200
|
||||
except Exception as e:
|
||||
app.logger.error(f"Health check failed: {str(e)}")
|
||||
return jsonify({
|
||||
'status': 'unhealthy',
|
||||
'error': str(e)
|
||||
'error': str(e),
|
||||
'timestamp': datetime.utcnow().isoformat()
|
||||
}), 500
|
||||
|
||||
# Initialize routes
|
||||
|
||||
Reference in New Issue
Block a user