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 utils import timeago
|
||||||
from extensions import db, login_manager, csrf
|
from extensions import db, login_manager, csrf
|
||||||
from utils.email_templates import create_default_templates
|
from utils.email_templates import create_default_templates
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
@@ -58,14 +59,18 @@ def create_app():
|
|||||||
try:
|
try:
|
||||||
# Check database connection
|
# Check database connection
|
||||||
db.session.execute('SELECT 1')
|
db.session.execute('SELECT 1')
|
||||||
|
db.session.commit()
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'healthy',
|
'status': 'healthy',
|
||||||
'database': 'connected'
|
'database': 'connected',
|
||||||
|
'timestamp': datetime.utcnow().isoformat()
|
||||||
}), 200
|
}), 200
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
app.logger.error(f"Health check failed: {str(e)}")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'unhealthy',
|
'status': 'unhealthy',
|
||||||
'error': str(e)
|
'error': str(e),
|
||||||
|
'timestamp': datetime.utcnow().isoformat()
|
||||||
}), 500
|
}), 500
|
||||||
|
|
||||||
# Initialize routes
|
# Initialize routes
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ services:
|
|||||||
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 5
|
||||||
|
start_period: 40s
|
||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
|
|||||||
Reference in New Issue
Block a user