Skip to content

Commit b1a33c8

Browse files
Merge pull request #68 from geoadmin/task-PB-1992-keepalive-greater-than-traefik
PB-1992: Add gunicorn keepalive env var
2 parents d80abbf + 448d8ce commit b1a33c8

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
@@ -181,3 +181,4 @@ The service is configured by Environment Variable:
181181
| ALLOWED_DOMAINS | `.*` | Comma separated list of regex that are allowed as domain in Origin header |
182182
| CACHE_CONTROL | `public, max-age=31536000` | Cache Control header value of the GET /generate endpoint |
183183
| CACHE_CONTROL_4XX | `public, max-age=3600` | Cache Control header for 4XX responses |
184+
| 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
@@ -21,5 +21,7 @@
2121
ALLOWED_DOMAINS_PATTERN = f"({'|'.join(ALLOWED_DOMAINS)})"
2222
TRAP_HTTP_EXCEPTIONS = True
2323

24+
GUNICORN_KEEPALIVE = int(os.getenv('GUNICORN_KEEPALIVE', '2'))
25+
2426
CACHE_CONTROL = os.getenv('CACHE_CONTROL', 'public, max-age=31536000')
2527
CACHE_CONTROL_4XX = os.getenv('CACHE_CONTROL_4XX', 'public, max-age=3600')

wsgi.py

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

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

89

910
class StandaloneApplication(BaseApplication): # pylint: disable=abstract-method
@@ -34,6 +35,7 @@ def load(self):
3435
'worker_class': 'gevent',
3536
'workers': 2, # scaling horizontally is left to Kubernetes
3637
'timeout': 60,
38+
'keepalive': GUNICORN_KEEPALIVE,
3739
'logconfig_dict': get_logging_cfg()
3840
}
3941
StandaloneApplication(application, options).run()

0 commit comments

Comments
 (0)