Commit e99abd1e by Max Rothman

Standardize edxapp env setup

Bring edxapp in line with other IDAs for how it sets its environment
variables. This includes adding shell scripts in between supervisor conf
files and gunicorn files.
parent 146f9251
......@@ -78,8 +78,8 @@ EDXAPP_ELASTIC_SEARCH_CONFIG:
- host: "localhost"
port: 9200
EDXAPP_LMS_ENV: 'lms.envs.aws'
EDXAPP_CMS_ENV: 'cms.envs.aws'
EDXAPP_LMS_ENV_FILE: 'lms.envs.aws'
EDXAPP_CMS_ENV_FILE: 'cms.envs.aws'
EDXAPP_EMAIL_BACKEND: 'django.core.mail.backends.smtp.EmailBackend'
EDXAPP_EMAIL_HOST: 'localhost'
......@@ -605,7 +605,8 @@ edxapp_helper_scripts:
- edxapp-update-assets
- edxapp-shell
edxapp_environment:
edxapp_common_environment: &edxapp_common_environment
LANG: "{{ EDXAPP_LANG }}"
NO_PREREQ_INSTALL: "{{ EDXAPP_NO_PREREQ_INSTALL }}"
SKIP_WS_MIGRATIONS: 1
......@@ -622,6 +623,27 @@ edxapp_environment:
# yaml based configs is complete
CONFIG_ROOT: "{{ edxapp_app_dir }}"
#NB: other apps (e.g. ecommerce) set these conditionally in *.sh.j2.
#In following the pattern set by how we handle settings files, I prefer this approach.
#Would like to discuss which we prefer before merging.
NEW_RELIC_APP_NAME: "{{ EDXAPP_NEWRELIC_LMS_APPNAME if COMMON_ENABLE_NEWRELIC_APP else None}}"
NEW_RELIC_LICENSE_KEY: "{{ NEWRELIC_LICENSE_KEY if COMMON_ENABLE_NEWRELIC_APP else None}}"
edxapp_lms_environment:
<<: *edxapp_common_environment
PORT: "{{ edxapp_lms_gunicorn_port }}"
ADDRESS: "{{ edxapp_lms_gunicorn_host }}"
DJANGO_SETTINGS_MODULE: "{{ EDXAPP_LMS_ENV_FILE }}"
SERVICE_VARIANT: lms
edxapp_cms_environment:
<<: *edxapp_common_environment
PORT: "{{ edxapp_cms_gunicorn_port }}"
ADDRESS: "{{ edxapp_cms_gunicorn_host }}"
DJANGO_SETTINGS_MODULE: "{{ EDXAPP_CMS_ENV_FILE }}"
SERVICE_VARIANT: cms
edxapp_generic_doc_store_config: &edxapp_generic_default_docstore
db: "{{ EDXAPP_MONGO_DB_NAME }}"
host: "{{ EDXAPP_MONGO_HOSTS }}"
......
- name: setup the edxapp env
- name: setup the lms env
template: >
src=edxapp_env.j2 dest={{ edxapp_app_dir }}/edxapp_env
src=lms_env.j2 dest={{ edxapp_app_dir }}/{{ EDXAPP_LMS_ENV_FILE }}
owner={{ edxapp_user }} group={{ common_web_user }}
mode=0644
tags:
- install
- install:configuration
- name: setup the cms env
template: >
src=cms_env.j2 dest={{ edxapp_app_dir }}/{{ EDXAPP_CMS_ENV_FILE }}
owner={{ edxapp_user }} group={{ common_web_user }}
mode=0644
tags:
- install
- install:configuration
- name: create edxapp configuration dir
file: >
path="{{ EDXAPP_CFG_DIR }}" state=directory
......@@ -14,7 +23,7 @@
tags:
- install
- install:configuration
# Optional auth for git
- name: create ssh script for git (not authenticated)
template: >
......@@ -24,7 +33,7 @@
tags:
- install
- install:base
- name: create ssh script for git (authenticated)
template: >
src=git_ssh_auth.sh.j2 dest={{ edxapp_git_ssh }}
......
......@@ -6,11 +6,10 @@
{% set executable = edxapp_venv_dir + '/bin/gunicorn' -%}
{% endif -%}
command={{ executable }} -c {{ edxapp_app_dir }}/cms_gunicorn.py {{ EDXAPP_CMS_GUNICORN_EXTRA }} cms.wsgi
command={{ edxapp_app_dir }}/cms.sh
user={{ common_web_user }}
directory={{ edxapp_code_dir }}
environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_CMS_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}PORT={{ edxapp_cms_gunicorn_port }},ADDRESS={{ edxapp_cms_gunicorn_host }},LANG={{ EDXAPP_LANG }},DJANGO_SETTINGS_MODULE={{ EDXAPP_CMS_ENV }},SERVICE_VARIANT="cms"
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log
killasgroup=true
......
#!/usr/bin/env bash
# {{ ansible_managed }}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + edxapp_venv_bin + '/gunicorn' %}
{% else %}
{% set executable = edxapp_venv_bin + '/gunicorn' %}
{% endif %}
source {{ EDXAPP_CMS_ENV_FILE }}
{{ executable }} -c {{ edxapp_app_dir }}/cms_gunicorn.py cms.wsgi
# {{ ansible_managed }}
{% for name,value in edxapp_environment.items() %}
{% for name,value in edxapp_cms_environment.items() %}
{%- if value %}
export {{ name }}="{{ value }}"
{%- endif %}
{%- endif %}
{% endfor %}
......@@ -6,11 +6,10 @@
{% set executable = edxapp_venv_dir + '/bin/gunicorn' -%}
{% endif -%}
command={{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi
command={{ edxapp_app_dir }}/lms.sh
user={{ common_web_user }}
directory={{ edxapp_code_dir }}
environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_LMS_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%} PORT={{ edxapp_lms_gunicorn_port }},ADDRESS={{ edxapp_lms_gunicorn_host }},LANG={{ EDXAPP_LANG }},DJANGO_SETTINGS_MODULE={{ EDXAPP_LMS_ENV }},SERVICE_VARIANT="lms",PATH="{{ edxapp_deploy_path }}"
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log
killasgroup=true
......
#!/usr/bin/env bash
# {{ ansible_managed }}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + edxapp_venv_bin + '/gunicorn' %}
{% else %}
{% set executable = edxapp_venv_bin + '/gunicorn' %}
{% endif %}
source {{ EDXAPP_LMS_ENV_FILE }}
{{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi
# {{ ansible_managed }}
{% for name,value in edxapp_lms_environment.items() %}
{%- if value %}
export {{ name }}="{{ value }}"
{%- endif %}
{% endfor %}
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