Always run Gunicorn (even when DEBUG=true) to ensure Socket.IO WebSocket (#341)

This commit is contained in:
CaliBrain
2025-12-13 00:21:44 -05:00
committed by GitHub
parent 122a3633c2
commit b293bee5f4
2 changed files with 9 additions and 19 deletions
+4 -7
View File
@@ -28,13 +28,10 @@ app.wsgi_app = ProxyFix(app.wsgi_app) # type: ignore
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 # Disable caching
app.config['APPLICATION_ROOT'] = '/'
# Determine async mode based on DEBUG setting
# In production (DEBUG=False) with Gunicorn + gevent worker, use 'gevent'
# In development (DEBUG=True) with Flask dev server, use 'threading'
if DEBUG:
async_mode = 'threading'
else:
async_mode = 'gevent'
# Socket.IO async mode.
# We run this app under Gunicorn with a gevent websocket worker (even when DEBUG=true),
# so Socket.IO should always use gevent here.
async_mode = 'gevent'
# Initialize Flask-SocketIO with reverse proxy support
socketio = SocketIO(