Skip to content

Commit 750d42a

Browse files
Merge pull request #146 from edx/nadeem/edxapp-gunicorn-logs
feat: Redirect edxapp Gunicorn logs to dedicated files
2 parents 58f6936 + e5e7c2b commit 750d42a

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

playbooks/roles/edxapp/defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ EDXAPP_CMS_GUNICORN_EXTRA: ""
3535
EDXAPP_CMS_GUNICORN_EXTRA_CONF: ""
3636
EDXAPP_CMS_GUNICORN_TIMEOUT: 300
3737

38+
EDXAPP_USE_GUNICORN_SEPARATE_LOG_FILE: False
39+
3840
# Set this to the maximum number
3941
# of requests for gunicorn for the lms and cms
4042
# gunicorn --max-requests <num>
@@ -1113,6 +1115,9 @@ EDXAPP_COMPLETION_AGGREGATOR_URL: null
11131115
edxapp_data_dir: "{{ COMMON_DATA_DIR }}/edxapp"
11141116
edxapp_app_dir: "{{ COMMON_APP_DIR }}/edxapp"
11151117
edxapp_log_dir: "{{ COMMON_LOG_DIR }}/edx"
1118+
edxapp_gunicorn_log_dir:
1119+
- "{{ COMMON_LOG_DIR }}/gunicorn-lms"
1120+
- "{{ COMMON_LOG_DIR }}/gunicorn-cms"
11161121
edxapp_venvs_dir: "{{ edxapp_app_dir }}/venvs"
11171122
edxapp_venv_dir: "{{ edxapp_venvs_dir }}/edxapp"
11181123
edxapp_venv_bin: "{{ edxapp_venv_dir }}/bin"

playbooks/roles/edxapp/tasks/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
- install
6060
- install:base
6161

62+
- name: create edxapp gunicorn log dirs
63+
file:
64+
path: "{{ item }}"
65+
state: directory
66+
owner: "{{ common_web_user }}"
67+
group: "{{ common_web_user }}"
68+
with_items:
69+
- "{{ edxapp_gunicorn_log_dir }}"
70+
tags:
71+
- install
72+
- install:base
73+
6274
- name: Ensure the tracking folder exists
6375
file:
6476
path: "{{ COMMON_LOG_DIR }}/tracking"

playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@ export EDX_REST_API_CLIENT_NAME="{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }
5151

5252
source {{ edxapp_app_dir }}/edxapp_env
5353
# We exec so that gunicorn is the child of supervisor and can be managed properly
54+
{% if EDXAPP_USE_GUNICORN_SEPARATE_LOG_FILE %}
55+
exec {{ executable }} -c {{ edxapp_app_dir }}/cms_gunicorn.py {{ EDXAPP_CMS_GUNICORN_EXTRA }} cms.wsgi --log-file {{ edxapp_gunicorn_log_dir[1] }}/edx.log
56+
{% else %}
5457
exec {{ executable }} -c {{ edxapp_app_dir }}/cms_gunicorn.py {{ EDXAPP_CMS_GUNICORN_EXTRA }} cms.wsgi
58+
{% endif %}

playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@ export EDX_REST_API_CLIENT_NAME="{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }
5252

5353
source {{ edxapp_app_dir }}/edxapp_env
5454
# We exec so that gunicorn is the child of supervisor and can be managed properly
55+
{% if EDXAPP_USE_GUNICORN_SEPARATE_LOG_FILE %}
56+
exec {{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi --log-file {{ edxapp_gunicorn_log_dir[0] }}/edx.log
57+
{% else %}
5558
exec {{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi
59+
{% endif %}

0 commit comments

Comments
 (0)