Skip to content

Commit 481dbd5

Browse files
committed
Make gunicorn max_requests configurable
1 parent 17f6e56 commit 481dbd5

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

desktop/conf.dist/hue.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ http_500_debug_mode=false
7878
# Workers still alive after the timeout (starting from the receipt of the restart signal) are force killed.
7979
# gunicorn_worker_graceful_timeout=900
8080

81+
# The maximum number of requests a worker will process before restarting.
82+
# gunicorn_max_requests=1200
83+
84+
# The maximum jitter to add to the max_requests setting.
85+
# gunicorn_max_requests_jitter=0
86+
8187
# Name of the Unix Domain Socket file for log listener communication.
8288
## log_listener_socket_name=hue.uds
8389

desktop/conf/pseudo-distributed.ini.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
# Workers still alive after the timeout (starting from the receipt of the restart signal) are force killed.
8484
# gunicorn_worker_graceful_timeout=900
8585

86+
# The maximum number of requests a worker will process before restarting.
87+
# gunicorn_max_requests=1200
88+
89+
# The maximum jitter to add to the max_requests setting.
90+
# gunicorn_max_requests_jitter=0
91+
8692
# Name of the Unix Domain Socket file for log listener communication.
8793
## log_listener_socket_name=hue.uds
8894

desktop/core/src/desktop/conf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ def is_custom_jwt_auth_enabled():
170170
return bool(AUTH.JWT.KEY_SERVER_URL.get())
171171

172172

173+
GUNICORN_MAX_REQUESTS = Config(
174+
key="gunicorn_max_requests",
175+
help=_("The maximum number of requests a worker will process before restarting."),
176+
type=int,
177+
default=1200)
178+
179+
GUNICORN_MAX_REQUESTS_JITTER = Config(
180+
key="gunicorn_max_requests_jitter",
181+
help=_("The maximum jitter to add to the max_requests setting."),
182+
type=int,
183+
default=0)
184+
173185
USE_CHERRYPY_SERVER = Config(
174186
key="use_cherrypy_server",
175187
help=_("If set to true, CherryPy will be used. Otherwise, Gunicorn will be used as the webserver."),

desktop/core/src/desktop/lib/gunicorn_server_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,9 @@ def gunicorn_ssl_context(conf, default_ssl_context_factory):
318318
'limit_request_fields': conf.LIMIT_REQUEST_FIELDS.get(),
319319
'limit_request_line': conf.LIMIT_REQUEST_LINE.get(),
320320
'loglevel': 'DEBUG' if conf.DJANGO_DEBUG_MODE.get() else 'INFO',
321-
'max_requests': 1200, # The maximum number of requests a worker will process before restarting.
322-
'max_requests_jitter': 0,
321+
# The maximum number of requests a worker will process before restarting.
322+
'max_requests': conf.GUNICORN_MAX_REQUESTS.get(),
323+
'max_requests_jitter': conf.GUNICORN_MAX_REQUESTS_JITTER.get(),
323324
'paste': None,
324325
'pidfile': None,
325326
'preload_app': False,

0 commit comments

Comments
 (0)