mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-19 06:54:20 +01:00
Allow setting SocketIO async mode from envvar or config.py (#773)
* Allow setting SocketIO async mode from envvar or config.py
This commit is contained in:
@@ -134,6 +134,7 @@ def create_app(config='CTFd.config.Config'):
|
||||
# If you have multiple workers you must have a shared cache
|
||||
socketio.init_app(
|
||||
app,
|
||||
async_mode=app.config.get('SOCKETIO_ASYNC_MODE'),
|
||||
message_queue=app.config.get('CACHE_REDIS_URL')
|
||||
)
|
||||
|
||||
|
||||
@@ -184,12 +184,19 @@ class Config(object):
|
||||
APPLICATION_ROOT:
|
||||
Specifies what path CTFd is mounted under. It can be used to run CTFd in a subdirectory.
|
||||
Example: /ctfd
|
||||
|
||||
SOCKETIO_ASYNC_MODE:
|
||||
Specifies what async mode SocketIO should use. The simplest but least performant option is 'threading'.
|
||||
Switching to a different async mode is not recommended without the appropriate load balancing mechanisms
|
||||
in place and proper understanding of how websockets are supported by Flask.
|
||||
https://flask-socketio.readthedocs.io/en/latest/#deployment
|
||||
'''
|
||||
REVERSE_PROXY = os.getenv("REVERSE_PROXY") or False
|
||||
TEMPLATES_AUTO_RELOAD = (not os.getenv("TEMPLATES_AUTO_RELOAD")) # Defaults True
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = (not os.getenv("SQLALCHEMY_TRACK_MODIFICATIONS")) # Defaults True
|
||||
UPDATE_CHECK = (not os.getenv("UPDATE_CHECK")) # Defaults True
|
||||
APPLICATION_ROOT = os.getenv('APPLICATION_ROOT') or '/'
|
||||
SOCKETIO_ASYNC_MODE = os.getenv('SOCKETIO_ASYNC_MODE') or 'threading'
|
||||
|
||||
'''
|
||||
=== OAUTH ===
|
||||
|
||||
@@ -2,4 +2,4 @@ from flask_socketio import SocketIO
|
||||
|
||||
# The choice to use threading is intentional to simplify deployment.
|
||||
# At the moment it is not recommended to build full-duplex systems inside CTFd.
|
||||
socketio = SocketIO(async_mode='threading')
|
||||
socketio = SocketIO()
|
||||
|
||||
Reference in New Issue
Block a user