Configure Docker to use Gunicorn instead of Flask development server for production deployment. Updated SocketIO configuration for gevent compatibility.

This commit is contained in:
2025-08-26 08:36:54 +00:00
parent eedaa253e4
commit 2fe272bd00
5 changed files with 28 additions and 6 deletions

View File

@@ -12,9 +12,10 @@ from config import config
from app.models import SimulationManager
# Initialize SocketIO with enhanced proxy support
# For Gunicorn compatibility, we need to set the async_mode to 'gevent'
socketio = SocketIO(
cors_allowed_origins="*",
async_mode='threading',
async_mode='gevent' if os.getenv('FLASK_ENV') == 'production' else 'threading',
logger=False, # Disable to avoid log spam in production
engineio_logger=False,
# Transport order: try websocket first, then polling
@@ -54,7 +55,7 @@ def create_app(config_name=None):
# Initialize extensions with proxy-friendly settings
socketio.init_app(
app,
async_mode='threading',
async_mode='gevent' if config_name == 'production' else 'threading',
cors_allowed_origins="*",
allow_upgrades=True,
transports=['websocket', 'polling'],