mirror of
https://github.com/chrisnov-it/quantumbotx.git
synced 2026-07-27 18:57:47 +00:00
Update README and add health check endpoint
Update README to reflect the correct script name for running the application. Add a health check endpoint to the Flask app to verify server status.
This commit is contained in:
@@ -95,7 +95,8 @@ DB_NAME=bots.db
|
||||
```
|
||||
5. **Run the application:**
|
||||
```bash
|
||||
python app.py
|
||||
|
||||
python run.py
|
||||
```
|
||||
|
||||
> **Important:** You must have the MetaTrader 5 terminal installed and running on the same machine.
|
||||
|
||||
@@ -4,6 +4,7 @@ import os
|
||||
import atexit
|
||||
import logging
|
||||
import MetaTrader5 as mt5
|
||||
from flask import jsonify
|
||||
from core import create_app
|
||||
from core.utils.mt5 import initialize_mt5
|
||||
from core.bots.controller import shutdown_all_bots, ambil_semua_bot
|
||||
@@ -21,6 +22,11 @@ def shutdown_app():
|
||||
# Panggil pabrik untuk membuat aplikasi kita
|
||||
app = create_app()
|
||||
|
||||
@app.route('/api/health')
|
||||
def health_check():
|
||||
"""Endpoint untuk memastikan server berjalan."""
|
||||
return jsonify({"status": "ok", "message": "Server is running"})
|
||||
|
||||
if __name__ == '__main__':
|
||||
# --- Inisialisasi MT5 Terpusat ---
|
||||
# Dilakukan di sini untuk memastikan hanya berjalan sekali.
|
||||
@@ -33,11 +39,14 @@ if __name__ == '__main__':
|
||||
ambil_semua_bot() # Muat bot setelah koneksi berhasil
|
||||
atexit.register(shutdown_app) # Daftarkan shutdown HANYA jika koneksi berhasil
|
||||
except Exception as e:
|
||||
logging.critical(f"GAGAL total saat inisialisasi MT5 di run.py: {e}", exc_info=True)
|
||||
logging.critical(
|
||||
f"GAGAL total saat inisialisasi MT5 di run.py: {e}",
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
app.run(
|
||||
debug=os.getenv('FLASK_DEBUG', 'False').lower() == 'true',
|
||||
host=os.getenv('FLASK_HOST', '127.0.0.1'),
|
||||
port=int(os.getenv('FLASK_PORT', 5000)),
|
||||
use_reloader=False # Ini tetap sangat penting
|
||||
use_reloader=False
|
||||
)
|
||||
Reference in New Issue
Block a user