chore: production docker + compose for LAN deployment
This commit is contained in:
39
wsgi.py
Normal file
39
wsgi.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""WSGI entrypoint for production deployments.
|
||||
|
||||
This module is what Gunicorn imports.
|
||||
We also start background tasks that are normally started in run.py:
|
||||
- UDP trigger listener
|
||||
- event expiry monitor
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from app import create_app
|
||||
from models import db
|
||||
from sockets import start_event_monitor
|
||||
from udp_listener import start_udp_listener
|
||||
|
||||
|
||||
app = create_app()
|
||||
|
||||
# Ensure DB exists on first boot (SQLite-based default).
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
|
||||
def _start_background_tasks() -> None:
|
||||
start_udp_listener(app)
|
||||
start_event_monitor(app)
|
||||
|
||||
|
||||
# With Gunicorn the module can be imported multiple times (worker processes).
|
||||
# This app is designed for LAN/kiosk setups; we intentionally run a single worker
|
||||
# by default to avoid duplicated UDP listeners.
|
||||
if os.environ.get("SYNCPLAYER_START_TASKS", "1") in ("1", "true", "yes"):
|
||||
_start_background_tasks()
|
||||
|
||||
|
||||
# Note: create_app() calls socketio.init_app(app), which wraps app.wsgi_app.
|
||||
# For Gunicorn, we can export the Flask app directly.
|
||||
Reference in New Issue
Block a user