Skip to content

Commit

Permalink
feat: Redirect edxapp Gunicorn logs to dedicated files
Browse files Browse the repository at this point in the history
  • Loading branch information
nadeemshahzad committed Jan 2, 2025
1 parent 58f6936 commit 96e817f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions playbooks/roles/edxapp/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ EDXAPP_CMS_GUNICORN_EXTRA: ""
EDXAPP_CMS_GUNICORN_EXTRA_CONF: ""
EDXAPP_CMS_GUNICORN_TIMEOUT: 300

EDXAPP_USE_GUNICORN_SEPARATE_LOG_FILE: False

# Set this to the maximum number
# of requests for gunicorn for the lms and cms
# gunicorn --max-requests <num>
Expand Down Expand Up @@ -1113,6 +1115,9 @@ EDXAPP_COMPLETION_AGGREGATOR_URL: null
edxapp_data_dir: "{{ COMMON_DATA_DIR }}/edxapp"
edxapp_app_dir: "{{ COMMON_APP_DIR }}/edxapp"
edxapp_log_dir: "{{ COMMON_LOG_DIR }}/edx"
edxapp_gunicorn_log_dir:
- "{{ COMMON_LOG_DIR }}/gunicorn-lms"
- "{{ COMMON_LOG_DIR }}/gunicorn-cms"
edxapp_venvs_dir: "{{ edxapp_app_dir }}/venvs"
edxapp_venv_dir: "{{ edxapp_venvs_dir }}/edxapp"
edxapp_venv_bin: "{{ edxapp_venv_dir }}/bin"
Expand Down
12 changes: 12 additions & 0 deletions playbooks/roles/edxapp/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
- install
- install:base

- name: create edxapp gunicorn log dirs
file:
path: "{{ item }}"
state: directory
owner: "{{ common_web_user }}"
group: "{{ common_web_user }}"
with_items:
- "{{ edxapp_gunicorn_log_dir }}"
tags:
- install
- install:base

- name: Ensure the tracking folder exists
file:
path: "{{ COMMON_LOG_DIR }}/tracking"
Expand Down
6 changes: 5 additions & 1 deletion playbooks/roles/edxapp/templates/edx/app/edxapp/cms.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ export EDX_REST_API_CLIENT_NAME="{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }

source {{ edxapp_app_dir }}/edxapp_env
# We exec so that gunicorn is the child of supervisor and can be managed properly
exec {{ executable }} -c {{ edxapp_app_dir }}/cms_gunicorn.py {{ EDXAPP_CMS_GUNICORN_EXTRA }} cms.wsgi
{% if EDXAPP_USE_GUNICORN_SEPARATE_LOG_FILE %}
exec {{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi --log-file {{ edxapp_gunicorn_log_dir[1] }}/edx.log
{% else %}
exec {{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi
{% endif %}
4 changes: 4 additions & 0 deletions playbooks/roles/edxapp/templates/edx/app/edxapp/lms.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ export EDX_REST_API_CLIENT_NAME="{{ COMMON_ENVIRONMENT }}-{{ COMMON_DEPLOYMENT }

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

0 comments on commit 96e817f

Please sign in to comment.