From 87dc6e0e9ea4d37d59828389c904f84460a3355b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Wed, 21 Feb 2018 10:02:54 +0000 Subject: [PATCH] Hubs: improve gunicorn config --- roles/hubs/defaults/main.yml | 1 + roles/hubs/tasks/webserver.yml | 14 ++++++++++++++ roles/hubs/templates/env | 2 +- roles/hubs/templates/gunicorn.py | 6 ++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 roles/hubs/templates/gunicorn.py diff --git a/roles/hubs/defaults/main.yml b/roles/hubs/defaults/main.yml index 8bda9fa967..11be883c82 100644 --- a/roles/hubs/defaults/main.yml +++ b/roles/hubs/defaults/main.yml @@ -5,6 +5,7 @@ hubs_base_dir: "/srv/hubs" hubs_code_dir: "{{ hubs_base_dir }}/fedora-hubs" hubs_conf_dir: "{{ hubs_base_dir }}/config" hubs_var_dir: "{{ hubs_base_dir }}/var" +hubs_log_dir: "{{ hubs_base_dir }}/log" hubs_db_type: sqlite hubs_db_user: hubs hubs_db_password: changeme diff --git a/roles/hubs/tasks/webserver.yml b/roles/hubs/tasks/webserver.yml index 9aecba8160..1c523782c3 100644 --- a/roles/hubs/tasks/webserver.yml +++ b/roles/hubs/tasks/webserver.yml @@ -59,6 +59,20 @@ persistent: yes +- name: Create the log directory + file: + path: "{{ hubs_log_dir }}" + owner: "{{ main_user }}" + state: directory + + +- name: Install the Gunicorn config file + template: + src: gunicorn.py + dest: "{{ hubs_conf_dir }}/gunicorn.py" + notify: "hubs configuration change" + + - name: Start and enable the services service: name={{ item }} state=started enabled=yes with_items: diff --git a/roles/hubs/templates/env b/roles/hubs/templates/env index e3c748125f..058139eb70 100644 --- a/roles/hubs/templates/env +++ b/roles/hubs/templates/env @@ -1,2 +1,2 @@ HUBS_CONFIG={{ hubs_conf_dir }}/hubs.py -LOGGING_CONFIG={{ hubs_conf_dir }}/logging.ini +WEBAPP_CONFIG={{ hubs_conf_dir }}/gunicorn.py diff --git a/roles/hubs/templates/gunicorn.py b/roles/hubs/templates/gunicorn.py new file mode 100644 index 0000000000..2fb44c0d0d --- /dev/null +++ b/roles/hubs/templates/gunicorn.py @@ -0,0 +1,6 @@ +bind = "127.0.0.1:8000" +threads = 12 +logconfig = "{{ hubs_conf_dir }}/logging.ini" +accesslog = "{{ hubs_log_dir }}/access.log" +errorlog = "{{ hubs_log_dir }}/error.log" +access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" (%(L)ss)'