Commit a24ec741 by Clinton Blackburn

Starting supervisor+nginx when running Docker

In addition to validating our supervisor and nginx configurations, this ensures we can serve static files locally as we would in production.
parent 70890cac
......@@ -2,6 +2,7 @@
credentials_gunicorn_host: 0.0.0.0
CREDENTIALS_MYSQL: 'db'
CREDENTIALS_DJANGO_SETTINGS_MODULE: 'credentials.settings.devstack'
CREDENTIALS_GUNICORN_EXTRA: '--reload'
CREDENTIALS_MYSQL_MATCHER: '%'
CREDENTIALS_MYSQL_HOST: 'db'
CREDENTIALS_MYSQL_PASSWORD: 'password'
......
......@@ -3,5 +3,6 @@ discovery_gunicorn_host: 0.0.0.0
DISCOVERY_MYSQL: 'db'
DISCOVERY_DJANGO_SETTINGS_MODULE: 'course_discovery.settings.devstack'
DISCOVERY_ELASTICSEARCH_HOST: 'es'
DISCOVERY_GUNICORN_EXTRA: '--reload'
COMMON_MYSQL_MIGRATE_USER: '{{ DISCOVERY_MYSQL_USER }}'
COMMON_MYSQL_MIGRATE_PASS: '{{ DISCOVERY_MYSQL_PASSWORD }}'
......@@ -10,17 +10,18 @@ case $COMMAND in
{{ '{%' }} set {{ role_name }}_venv_bin = {{ role_name }}_home + "/venvs/" + {{ role_name }}_service_name + "/bin" %}
{{ '{%' }} set executable = {{ role_name }}_venv_bin + '/gunicorn' %}
{{ '{{' }} supervisor_venv_bin }}/supervisord --configuration {{ '{%' }}supervisor_cfg }}
cd /edx/app/edx_ansible/edx_ansible/docker/plays
sudo /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook {{ role_name }}.yml -c local -i '127.0.0.1,' \
-t 'install:app-requirements,assets:gather,devstack,migrate' \
/edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook {{ role_name }}.yml -c local -i '127.0.0.1,' \
-t 'install:app-requirements,assets:gather,devstack,migrate,manage:start' \
--extra-vars="migrate_db=yes" \
--extra-vars="@/ansible_overrides.yml"
{{ '{{' }} executable }} -c {{ '{{' }} {{ role_name }}_home }}/{{ role_name }}_gunicorn.py \
{{ '{{' }} {{ role_name|upper }}_GUNICORN_EXTRA }} \
--reload \
{{ role_name }}.wsgi:application
# Docker requires an active foreground task. Tail the logs to appease Docker and
# provide useful output for development.
cd {{ '{{' }} supervisor_log_dir }}
tail -f {{ '{{' }} {{ role_name }}_service_name }}-stderr.log -f {{ '{{' }} {{ role_name }}_service_name }}-stdout.log
;;
open)
cd {{ '{{' }} {{ role_name }}_code_dir }}/
......
......@@ -8,18 +8,19 @@ COMMAND=$1
case $COMMAND in
start)
{% set credentials_venv_bin = credentials_home + "/venvs/" + credentials_service_name + "/bin" %}
{% set executable = credentials_venv_bin + '/gunicorn' %}
{{ supervisor_venv_bin }}/supervisord --configuration {{ supervisor_cfg }}
cd /edx/app/edx_ansible/edx_ansible/docker/plays
sudo /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook credentials.yml -c local -i '127.0.0.1,' \
/edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook credentials.yml -c local -i '127.0.0.1,' \
-t 'install:app-requirements,assets:gather,devstack,migrate,manage:start' \
--extra-vars="migrate_db=yes" \
--extra-vars="@/ansible_overrides.yml"
{{ executable }} -c {{ credentials_home }}/credentials_gunicorn.py \
{{ CREDENTIALS_GUNICORN_EXTRA }} \
--reload \
credentials.wsgi:application
# Docker requires an active foreground task. Tail the logs to appease Docker and
# provide useful output for development.
cd {{ supervisor_log_dir }}
tail -f {{ credentials_service_name }}-stderr.log -f {{ credentials_service_name }}-stdout.log
;;
open)
......
......@@ -8,20 +8,19 @@ COMMAND=$1
case $COMMAND in
start)
{% set discovery_venv_bin = discovery_home + "/venvs/" + discovery_service_name + "/bin" %}
{% set executable = discovery_venv_bin + '/gunicorn' %}
cd /edx/app/edx_ansible/edx_ansible/docker/plays
{{ supervisor_venv_bin }}/supervisord --configuration {{ supervisor_cfg }}
sudo ansible-playbook discovery.yml -c local -i '127.0.0.1,' \
-t 'install:app-requirements,assets:gather,devstack,migrate' \
cd /edx/app/edx_ansible/edx_ansible/docker/plays
ansible-playbook discovery.yml -c local -i '127.0.0.1,' \
-t 'install:app-requirements,assets:gather,devstack,migrate,manage:start' \
--extra-vars="migrate_db=yes" \
--extra-vars="@/ansible_overrides.yml"
{{ executable }} -c {{ discovery_home }}/discovery_gunicorn.py \
{{ DISCOVERY_GUNICORN_EXTRA }} \
--reload \
course_discovery.wsgi:application
# Docker requires an active foreground task. Tail the logs to appease Docker and
# provide useful output for development.
cd {{ supervisor_log_dir }}
tail -f {{ discovery_service_name }}-stderr.log -f {{ discovery_service_name }}-stdout.log
;;
open)
cd {{ discovery_code_dir }}
......
......@@ -215,7 +215,7 @@
register: start_supervisor
tags:
- manage
- manager:start
- manage:start
# calling update on supervisor too soon after it
# starts will result in an errror.
......
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