Files
location_managemet/run.py
2026-02-26 19:24:17 +02:00

42 lines
1.0 KiB
Python

"""Application entry point.
Run with:
python run.py
Or for production:
gunicorn -w 1 -k eventlet "run:create_socketio_app()"
"""
import os
import threading
import time
from app import create_app, socketio
from app.services.board_service import poll_all_boards
app = create_app(os.environ.get("FLASK_ENV", "development"))
def _background_poller():
"""Poll all boards in a loop every BOARD_POLL_INTERVAL seconds."""
interval = app.config.get("BOARD_POLL_INTERVAL", 10)
while True:
try:
poll_all_boards(app)
except Exception as exc:
app.logger.warning("Poller error: %s", exc)
time.sleep(interval)
def create_socketio_app():
"""WSGI callable for gunicorn / production."""
return socketio.middleware(app)
if __name__ == "__main__":
# Start background board poller
t = threading.Thread(target=_background_poller, daemon=True)
t.start()
port = int(os.environ.get("PORT", 5000))
socketio.run(app, host="0.0.0.0", port=port, debug=app.debug, allow_unsafe_werkzeug=True)