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:
Reynov Christian
2025-08-15 16:28:54 +08:00
parent 8490b3129b
commit dfb7e0ebd1
2 changed files with 13 additions and 3 deletions
+2 -1
View File
@@ -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.
+11 -2
View File
@@ -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
)