-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathdocker-entrypoint.py
More file actions
47 lines (41 loc) · 1.25 KB
/
docker-entrypoint.py
File metadata and controls
47 lines (41 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
"""
RustChain Node Entrypoint with Health Check
Adds a /health endpoint to rustchain_dashboard.py
"""
import sys
import os
# Add node directory to path
sys.path.insert(0, '/app/node')
# Import the Flask app from rustchain_dashboard
from rustchain_dashboard import app
# Add health check endpoint
@app.route('/health')
def health_check():
"""Simple health check endpoint for Docker healthcheck"""
import sqlite3
from flask import jsonify
try:
# Check if database is accessible
db_path = os.environ.get('RUSTCHAIN_DB', '/rustchain/data/rustchain_v2.db')
if os.path.exists(db_path):
conn = sqlite3.connect(db_path, timeout=5)
conn.execute('SELECT 1')
conn.close()
db_status = 'ok'
else:
db_status = 'initializing'
return jsonify({
'status': 'healthy',
'database': db_status,
'version': '2.2.1-docker'
}), 200
except Exception as e:
return jsonify({
'status': 'unhealthy',
'error': str(e)
}), 503
if __name__ == '__main__':
# Run the app
port = int(os.environ.get('PORT', 8099))
app.run(host='0.0.0.0', port=port, debug=False)