Commit 2b556f2b by Carson Gee

Convert xqueue gunicorn configuration to file

parent b9362da8
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
--- ---
XQUEUE_NGINX_PORT: 18040 XQUEUE_NGINX_PORT: 18040
XQUEUE_GUNICORN_WORKERS_EXTRA: "" XQUEUE_GUNICORN_WORKERS_EXTRA: ""
XQUEUE_GUNICORN_EXTRA: "" XQUEUE_GUNICORN_WORKERS_EXTRA_CONF: ""
XQUEUE_QUEUES: XQUEUE_QUEUES:
# push queue # push queue
'edX-Open_DemoX': 'http://localhost:18050' 'edX-Open_DemoX': 'http://localhost:18050'
......
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
with_items: ['xqueue', 'xqueue_consumer'] with_items: ['xqueue', 'xqueue_consumer']
when: not disable_edx_services when: not disable_edx_services
- name: "add gunicorn configuration file"
template: >
src=xqueue_gunicorn.py.j2 dest={{ xqueue_app_dir }}/xqueue_gunicorn.py
sudo_user: "{{ xqueue_user }}"
notify:
- restart xqueue
- name: create xqueue application config - name: create xqueue application config
template: src=xqueue.env.json.j2 dest={{ xqueue_app_dir }}/xqueue.env.json mode=0644 template: src=xqueue.env.json.j2 dest={{ xqueue_app_dir }}/xqueue.env.json mode=0644
......
...@@ -6,15 +6,7 @@ ...@@ -6,15 +6,7 @@
{% set executable = xqueue_venv_bin + '/gunicorn' %} {% set executable = xqueue_venv_bin + '/gunicorn' %}
{% endif %} {% endif %}
{% if XQUEUE_WORKERS -%} command={{ executable }} -c {{ xqueue_app_dir }}/xqueue_gunicorn.py {{ XQUEUE_GUNICORN_WORKERS_EXTRA }} xqueue.wsgi
command={{ executable }} --preload -b {{ xqueue_gunicorn_host }}:{{ xqueue_gunicorn_port }} -w {{ XQUEUE_WORKERS }} --timeout=300 --pythonpath={{ xqueue_code_dir }} {{ XQUEUE_GUNICORN_WORKERS_EXTRA }} xqueue.wsgi
{% else -%}
{% if ansible_processor|length > 0 %}
command={{ executable }} --preload -b {{ xqueue_gunicorn_host }}:{{ xqueue_gunicorn_port }} -w {{ ansible_processor|length * 2 }} --timeout=300 --pythonpath={{ xqueue_code_dir }} {{ XQUEUE_GUNICORN_EXTRA }} xqueue.wsgi
{% else -%}
command={{ executable }} --preload -b {{ xqueue_gunicorn_host }}:{{ xqueue_gunicorn_port }} -w 2 --timeout=300 --pythonpath={{ xqueue_code_dir }} {{ XQUEUE_GUNICORN_EXTRA }} xqueue.wsgi
{% endif -%}
{% endif -%}
user={{ common_web_user }} user={{ common_web_user }}
directory={{ xqueue_code_dir }} directory={{ xqueue_code_dir }}
......
"""
gunicorn configuration file: http://docs.gunicorn.org/en/develop/configure.html
{{ ansible_managed }}
"""
import multiprocessing
preload_app = True
timeout = 300
bind = "{{ xqueue_gunicorn_host }}:{{ xqueue_gunicorn_port }}"
pythonpath = "{{ xqueue_code_dir }}"
{% if XQUEUE_WORKERS %}
workers = {{ XQUEUE_WORKERS }}
{% else %}
workers = (multiprocessing.cpu_count()-1) * 2 + 2
{% endif %}
{{ XQUEUE_GUNICORN_WORKERS_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