Commit 9761623e by Renzo Lucioni

Allow ecommerce gunicorn workers to be regularly restarted

Leverages gunicorn's max-requests option to restart workers after they've processed a configured number of requests. Also adds this option to cookiecutter role. ECOM-5448.
parent c4ef75c1
......@@ -93,6 +93,7 @@
{{ role_name|upper }}_GUNICORN_EXTRA: ""
{{ role_name|upper }}_GUNICORN_EXTRA_CONF: ""
{{ role_name|upper }}_GUNICORN_WORKER_CLASS: "gevent"
{{ role_name|upper }}_GUNICORN_MAX_REQUESTS: !!null
{{ role_name|upper }}_HOSTNAME: '~^((stage|prod)-)?{{ role_name|replace('_', '-') }}.*'
......
......@@ -9,4 +9,8 @@ pythonpath = "{{ '{{' }} {{ role_name }}_code_dir }}"
workers = {{ '{{' }} {{ role_name|upper }}_GUNICORN_WORKERS }}
worker_class = "{{ '{{' }} {{ role_name|upper }}_GUNICORN_WORKER_CLASS }}"
{{ '{%' }} if {{ role_name|upper }}_GUNICORN_MAX_REQUESTS {{ '%}' }}
max_requests = {{ '{{' }} {{ role_name|upper }}_GUNICORN_MAX_REQUESTS }}
{{ '{%' }} endif {{ '%}' }}
{{ '{{' }} {{ role_name|upper }}_GUNICORN_EXTRA_CONF }}
......@@ -198,6 +198,7 @@ ECOMMERCE_GUNICORN_WORKERS: "2"
ECOMMERCE_GUNICORN_EXTRA: ""
ECOMMERCE_GUNICORN_EXTRA_CONF: ""
ECOMMERCE_GUNICORN_WORKER_CLASS: "gevent"
ECOMMERCE_GUNICORN_MAX_REQUESTS: !!null
#
# vars are namespace with the module name.
......
......@@ -9,4 +9,8 @@ pythonpath = "{{ ecommerce_code_dir }}"
workers = {{ ECOMMERCE_GUNICORN_WORKERS }}
worker_class = "{{ ECOMMERCE_GUNICORN_WORKER_CLASS }}"
{% if ECOMMERCE_GUNICORN_MAX_REQUESTS %}
max_requests = {{ ECOMMERCE_GUNICORN_MAX_REQUESTS }}
{% endif %}
{{ ECOMMERCE_GUNICORN_EXTRA_CONF }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment