Commit 27a93364 by Fred Smith

restructure notes_api deployment

parent a514fb9c
......@@ -28,6 +28,7 @@ EDX_NOTES_API_CLIENT_ID: "CHANGEME"
EDX_NOTES_API_CLIENT_SECRET: "CHANGEME"
EDX_NOTES_API_GIT_SSH_KEY: !!null
EDX_NOTES_API_VERSION: master
EDX_NOTES_API_DJANGO_SETTINGS_MODULE: 'notesserver.settings.yaml_config'
EDX_NOTES_API_DATABASES:
# rw user
......@@ -81,11 +82,21 @@ edx_notes_api_service_config:
#
# vars are namespace with the module name.
#
edx_notes_api_environment:
EDXNOTES_CONFIG_ROOT: "{{ COMMON_CFG_DIR }}"
LANG: "{{ EDX_NOTES_API_LANG }}"
DJANGO_SETTINGS_MODULE: "{{ EDX_NOTES_API_DJANGO_SETTINGS_MODULE }}"
SERVICE_VARIANT: "{{ edx_notes_api_service_name }}"
PATH: "{{ edx_notes_api_venv_dir }}/bin:{{ ansible_env.PATH }}"
edx_notes_api_service_name: edx_notes_api
edx_notes_api_user: "{{ edx_notes_api_service_name }}"
edx_notes_api_home: "{{ COMMON_APP_DIR }}/{{ edx_notes_api_service_name }}"
edx_notes_api_code_dir: "{{ edx_notes_api_home }}/{{ edx_notes_api_service_name }}"
edx_notes_api_conf_dir: "{{ edx_notes_api_home }}"
edx_notes_api_venv_dir: "{{ edx_notes_api_home }}/venvs/{{ edx_notes_api_service_name }}"
edx_notes_api_gunicorn_host: "127.0.0.1"
edx_notes_api_gunicorn_port: 8120
......
......@@ -71,6 +71,18 @@
tags:
- deploy
- name: write out the supervisor wrapper
template:
src: "edx/app/edx_notes_api/edx_notes_api.sh.j2"
dest: "{{ edx_notes_api_home }}/{{ edx_notes_api_service_name }}.sh"
mode: 0650
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
tags:
- install
- install:configuration
- name: write supervisord config
template: >
src=edx/app/supervisor/conf.d.available/edx_notes_api.conf.j2
......@@ -79,6 +91,18 @@
tags:
- deploy
- name: setup the edx_notes_api env file
template:
src: "edx/app/edx_notes_api/edx_notes_api_env.j2"
dest: "{{ edx_notes_api_home }}/{{ edx_notes_api_service_name}}_env"
owner: "{{ edx_notes_api_user }}"
group: "{{ edx_notes_api_user }}"
mode: 0644
tags:
- install
- install:configuration
- name: enable supervisor script
file: >
src={{ supervisor_available_dir }}/{{ edx_notes_api_service_name }}.conf
......
#!/usr/bin/env bash
# {{ ansible_managed }}
{% set edx_notes_api_venv_bin = edx_notes_api_home + '/venvs/' + edx_notes_api_service_name + '/bin' %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = edx_notes_api_venv_bin + '/newrelic-admin run-program ' + edx_notes_api_venv_bin + '/gunicorn' %}
{% else %}
{% set executable = edx_notes_api_venv_bin + '/gunicorn' %}
{% endif %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
export NEW_RELIC_APP_NAME="{{ EDX_NOTES_API_NEWRELIC_APPNAME }}"
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% endif -%}
source {{ edx_notes_api_home }}/edx_notes_api_env
export PID=/var/tmp/edx_notes_api.pid
export PORT={{ edx_notes_api_gunicorn_port }}
export ADDRESS={{ edx_notes_api_gunicorn_host }}
{{ executable }} -c {{ edx_notes_api_home }}/edx_notes_api_gunicorn.py {{ EDX_NOTES_API_GUNICORN_WORKERS_EXTRA }} {{ edx_notes_api_wsgi }}
# {{ ansible_managed }}
{% for name,value in edx_notes_api_environment.items() -%}
{%- if value -%}
export {{ name }}="{{ value }}"
{% endif %}
{%- endfor %}
[program:{{ edx_notes_api_service_name }}]
{% set edx_notes_api_venv_bin = edx_notes_api_home + '/venvs/' + edx_notes_api_service_name + '/bin' %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = edx_notes_api_venv_bin + '/newrelic-admin run-program ' + edx_notes_api_venv_bin + '/gunicorn' %}
{% else %}
{% set executable = edx_notes_api_venv_bin + '/gunicorn' %}
{% endif %}
#
# {{ ansible_managed }}
#
command={{ executable }} -c {{ edx_notes_api_home }}/edx_notes_api_gunicorn.py {{ EDX_NOTES_API_GUNICORN_WORKERS_EXTRA }} {{ edx_notes_api_wsgi }}
[program:{{ edx_notes_api_service_name }}]
command={{ edx_notes_api_home }}/{{ edx_notes_api_service_name }}.sh
user={{ common_web_user }}
directory={{ edx_notes_api_code_dir }}
environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDX_NOTES_API_NEWRELIC_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}PID=/var/tmp/edx_notes_api.pid,PORT={{ edx_notes_api_gunicorn_port }},ADDRESS={{ edx_notes_api_gunicorn_host }},LANG={{ EDX_NOTES_API_LANG }},DJANGO_SETTINGS_MODULE=notesserver.settings.yaml_config,SERVICE_VARIANT="{{ edx_notes_api_service_name }}",EDXNOTES_CONFIG_ROOT="{{ COMMON_CFG_DIR }}"
stdout_logfile={{ supervisor_log_dir }}/%(program_name)-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)-stderr.log
killasgroup=true
......
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