Skip to content

Commit e07536e

Browse files
Merge pull request #99 from geoadmin/task-PB-1992-increase-keepalive-greater-than-traefik
PB-1992 : Add gunicorn keepalive env var
2 parents 7d1de38 + a4e8fcb commit e07536e

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,4 @@ The service is configured by Environment Variable:
193193
| GUNICORN_TMPFS_DIR | `None` |The working directory for the gunicorn workers. |
194194
| WSGI_WORKERS | `2` | The number of workers per CPU. |
195195
| UNLISTED_ICON_SETS | | Comma separated list of icon set to un-list. Those sets won't be listed in the /sets endpoint. |
196+
| GUNICORN_KEEPALIVE | `2` | The [`keepalive`](https://docs.gunicorn.org/en/stable/settings.html#keepalive) setting passed to gunicorn. |

app/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
os.environ['LOGS_DIR'] = LOGS_DIR # Set default if not set
2929
LOGGING_CFG = os.getenv('LOGGING_CFG', 'logging-cfg-local.yml')
3030

31+
GUNICORN_KEEPALIVE = int(os.getenv('GUNICORN_KEEPALIVE', '2'))
32+
3133
# Definition of the allowed domains for CORS implementation
3234
ALLOWED_DOMAINS = os.getenv('ALLOWED_DOMAINS', r'.*').split(',')
3335
CACHE_CONTROL = os.getenv('CACHE_CONTROL', 'public, max-age=86400')

wsgi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from app import app as application
66
from app.helpers import get_logging_cfg
7+
from app.settings import GUNICORN_KEEPALIVE
78

89

910
class StandaloneApplication(BaseApplication): # pylint: disable=abstract-method
@@ -36,6 +37,7 @@ def load(self):
3637
'workers': int(os.getenv('WSGI_WORKERS',
3738
'2')), # scaling horizontally is left to Kubernetes
3839
'timeout': int(os.getenv('WSGI_TIMEOUT', '5')),
40+
'keepalive': GUNICORN_KEEPALIVE,
3941
'logconfig_dict': get_logging_cfg(),
4042
'forwarded_allow_ips': os.getenv('FORWARED_ALLOW_IPS', '*'),
4143
'secure_scheme_headers': {

0 commit comments

Comments
 (0)