Commit 5bf89ac0 by John Jarvis

moves discern over to celery, creates some deploy plays

parent ba8e364f
- name: Deploy certs
hosts: all
sudo: True
gather_facts: True
roles:
- common
- supervisor
- certs
- name: Deploy devpi
hosts: all
sudo: True
gather_facts: True
roles:
- common
- supervisor
- devpi
- name: Deploy discern
hosts: all
sudo: True
gather_facts: True
roles:
- common
- supervisor
- discern
......@@ -11,6 +11,7 @@ DISCERN_MYSQL_USER: 'root'
DISCERN_MYSQL_PASSWORD: ''
DISCERN_MYSQL_HOST: 'localhost'
DISCERN_MYSQL_PORT: '3306'
DISCERN_LANG: "en_US.UTF-8"
discern_app_dir: "{{ COMMON_APP_DIR }}/discern"
......@@ -38,6 +39,7 @@ discern_branch: dev
discern_gunicorn_port: 8070
discern_gunicorn_host: 127.0.0.1
discern_worker_mult: 2
discern_env_config:
ACCOUNT_EMAIL_VERIFICATION: "mandatory"
AWS_SES_REGION_NAME: "us-east-1"
......
---
- name: discern | restart discern
service: name=discern state=restarted
supervisorctl: >
name=discern
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=restarted
- name: discern | restart celery
service: name=celery state=restarted
- name: discern | restart discern_celery
supervisorctl: >
name=discern_celery
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=restarted
---
- name: discern | See if supervisord config file `discern.conf` is installed
shell: "[ -f {{ supervisor_cfg_dir }}/discern.conf ] && echo 'Found' || echo ''"
register: discern_installed
tags:
- deploy
- name: discern | See if supervisord `discern_celery.conf` is installed
shell: "[ -f {{ supervisor_cfg_dir }}/discern_celery.conf ] && echo 'Found' || echo ''"
register: discern_celery_installed
tags:
- deploy
# Stop discern service.
- name: discern | stop discern service
supervisorctl: >
name=discern
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=stopped
when: discern_installed.stdout == 'Found'
notify: discern | restart discern
tags:
- deploy
- name: discern | stop discern_celery service
supervisorctl: >
name=discern_celery
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=stopped
when: discern_celery_installed.stdout == 'Found'
notify: discern | restart discern_celery
tags:
- deploy
- name: discern | create supervisor scripts - discern, discern_celery
template: >
src={{ item }}.conf.j2 dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
with_items: ['discern', 'discern_celery']
tags:
- deploy
#Upload config files for django (auth and env)
- name: discern | create discern application config env.json file
template: src=env.json.j2 dest={{ discern_app_dir }}/env.json
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern_celery
- discern | restart discern
tags:
- deploy
......@@ -13,7 +58,7 @@
template: src=auth.json.j2 dest={{ discern_app_dir }}/auth.json
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern_celery
- discern | restart discern
tags:
- deploy
......@@ -22,7 +67,7 @@
git: dest={{ discern_code_dir }} repo={{ discern_source_repo }} version={{ discern_branch }}
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern_celery
- discern | restart discern
tags:
- deploy
......@@ -31,7 +76,7 @@
git: dest={{ discern_ease_code_dir}} repo={{ discern_ease_source_repo }} version={{ discern_ease_version }}
sudo_user: "{{ discern_user }}"
notify:
- discern | restart celery
- discern | restart discern_celery
- discern | restart discern
tags:
- deploy
......
......@@ -6,7 +6,7 @@
createhome=no
shell=/bin/false
- name: discern | create discern app and data dir
- name: discern | create discern app dirs owned by discern
file: >
path="{{ item }}"
state=directory
......@@ -14,9 +14,13 @@
group="{{ common_web_group }}"
with_items:
- "{{ discern_app_dir }}"
- "{{ discern_data_dir }}"
- "{{ discern_venvs_dir }}"
- name: discern | create discern data dir, owned by {{ common_web_user }}
file: >
path="{{ discern_data_dir }}" state=directory
owner="{{ common_web_user }}"
- name: discern | install debian packages that discern needs
apt: pkg={{ item }} state=present
with_items: discern_debian_pkgs
......
# gunicorn
description "ML API Server"
author "Vik Paruchuri <vik@edx.org>"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 3 30
env PID=/var/run/gunicorn/discern.pid
env WORKERS={{ ansible_processor_cores * 2 }}
env PORT={{ discern_gunicorn_port }}
env ADDRESS={{ discern_gunicorn_host }}
env LANG=en_US.UTF-8
env DJANGO_SETTINGS_MODULE={{ discern_settings }}
chdir {{ discern_code_dir }}
setuid {{ discern_user }}
exec {{ discern_venv_bin }}/gunicorn --preload -b $ADDRESS:$PORT -w $WORKERS --timeout=30 --pythonpath={{ discern_code_dir }} discern.wsgi
[program:discern]
{% if ansible_processor|length > 0 %}
command={{ discern_venv_bin }}/gunicorn --preload -b {{ discern_gunicorn_host }}:{{ discern_gunicorn_port }} -w {{ ansible_processor|length * discern_worker_mult }} --timeout=30 --pythonpath={{ discern_code_dir }} discern.wsgi
{% else %}
command={{ discern_venv_bin }}/gunicorn --preload -b {{ discern_gunicorn_host }}:{{ discern_gunicorn_port }} -w {{ discern_worker_mult }} --timeout=30 --pythonpath={{ discern_code_dir }} discern.wsgi
{% endif %}
user={{ common_web_user }}
directory={{ discern_code_dir }}
environment=LANG={{ DISCERN_LANG }},DJANGO_SETTINGS_MODULE={{ discern_settings }},SERVICE_VARIANT=discern
stdout_logfile={{ supervisor_log_dir }}/%(program_name)-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)-stderr.log
[program:discern_celery]
command={{ discern_venv_bin }}/python {{ discern_code_dir }}/manage.py celeryd --loglevel=info --settings=edx_discern.aws --pythonpath={{ discern_code_dir }} -B --autoscale=4,1 --schedule={{ discern_data_dir }}/celerybeat-schedule
user={{ common_web_user }}
directory={{ discern_code_dir }}
environment=DJANGO_SETTINGS_MODULE=edx_discern.aws,SERVICE_VARIANT=discern
stdout_logfile={{ supervisor_log_dir }}/%(program_name)-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)-stderr.log
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