Commit aeeafffb by John Jarvis

Merge pull request #404 from antoviaque/supervisor-xserver

Move xserver to supervisor
parents d19a3ab7 51b75c4b
......@@ -56,8 +56,15 @@
tags:
- deploy
- name: ora | reload supervisor to allow to start the new services
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} reload"
- name: ora | ensuring ora and ora_celery are activated in supervisor
supervisorctl: >
name="{{ item }}"
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=present
with_items: ['ora', 'ora_celery']
tags:
- deploy
# Do A Checkout
- name: ora | git checkout ora repo into {{ ora_app_dir }}
......
......@@ -37,8 +37,15 @@
tags:
- deploy
- name: xqueue | reload supervisor to allow to start the new services
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} reload"
- name: xqueue | ensuring xqueue and xqueue_consumer are activated in supervisor
supervisorctl: >
name="{{ item }}"
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=present
with_items: ['xqueue', 'xqueue_consumer']
tags:
- deploy
# Do A Checkout
- name: xqueue | git checkout xqueue repo into xqueue_code_dir
......
......@@ -15,6 +15,8 @@ XSERVER_GRADER_SOURCE: !!null
# Example: "{{ secure_dir }}/files/git-identity"
XSERVER_LOCAL_GIT_IDENTITY: !!null
XSERVER_LANG: "en_US.UTF-8"
# Internal role vars below this line
xserver_app_dir: "{{ COMMON_APP_DIR }}/xserver"
......@@ -49,6 +51,7 @@ xserver_requirements_file: "{{ xserver_code_dir }}/requirements.txt"
xserver_gunicorn_port: 8050
xserver_gunicorn_host: 'localhost'
xserver_gunicorn_workers: "{{ ansible_processor|length }}"
xserver_debian_pkgs:
- build-essential
......
- name: xserver | stop xserver
service: name=xserver state=stopped
supervisorctl: >
name=xserver
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=stopped
tags:
- deploy
......@@ -9,6 +13,22 @@
tags:
- deploy
- name: "xserver | writing supervisor script"
template: >
src=xserver.conf.j2 dest={{ supervisor_cfg_dir }}/xserver.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
tags:
- deploy
- name: xserver | ensuring xserver is activated in supervisor
supervisorctl: >
name="xserver"
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=present
tags:
- deploy
- name: xserver | install requirements
pip: requirements="{{xserver_requirements_file}}" virtualenv="{{ xserver_venv_dir }}" state=present
sudo_user: "{{ xserver_user }}"
......@@ -55,6 +75,10 @@
- deploy
- name: xserver | start xserver
service: name=xserver state=started
supervisorctl: >
name=xserver
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
tags:
- deploy
......@@ -24,7 +24,6 @@
createhome=no
shell=/bin/false
- name: xserver | create xserver app and data dirs
file: >
path="{{ item }}"
......@@ -63,9 +62,6 @@
- "{{ secure_dir }}/files/edx_apparmor_sandbox.j2"
- "usr.bin.python-sandbox.j2"
- name: xserver | setup upstart script
template: src=xserver.conf.j2 dest=/etc/init/xserver.conf owner=root group=root
- include: deploy.yml
- name: xserver | enforce app-armor rules
......
# gunicorn
[program:xserver]
description "gunicorn server"
author "Calen Pennington <cpennington@mitx.mit.edu>"
command={{ xserver_venv_bin }}/gunicorn --preload -b {{ xserver_gunicorn_host }}:{{ xserver_gunicorn_port }} -w {{ xserver_gunicorn_workers }} --timeout=30 --pythonpath={{ xserver_code_dir }} pyxserver_wsgi:application
start on started edxapp
stop on stopped edxapp
user={{ common_web_user }}
directory={{ xserver_code_dir }}
respawn
respawn limit 3 30
environment=PID=/var/tmp/xserver.pid,NEW_RELIC_CONFIG_FILE={{ xserver_app_dir }}/newrelic.ini,NEWRELIC={{ xserver_venv_dir }}/bin/newrelic-admin,PORT={{ xserver_gunicorn_port }},ADDRESS={{ xserver_gunicorn_host }},LANG={{ XSERVER_LANG }},DJANGO_SETTINGS_MODULE=xserver_aws_settings,SERVICE_VARIANT="xserver"
env PID=/var/tmp/xserver.pid
env NEW_RELIC_CONFIG_FILE={{ xserver_app_dir }}/newrelic.ini
env NEWRELIC={{ xserver_venv_dir }}/bin/newrelic-admin
env WORKERS={{ ansible_processor|length }}
env PORT={{ xserver_gunicorn_port }}
env ADDRESS={{ xserver_gunicorn_host }}
env LANG=en_US.UTF-8
env DJANGO_SETTINGS_MODULE=xserver_aws_settings
env SERVICE_VARIANT="xserver"
chdir {{ xserver_code_dir }}
setuid www-data
exec {{ xserver_venv_dir }}/bin/gunicorn --preload -b $ADDRESS:$PORT -w $WORKERS --timeout=30 --pythonpath={{ xserver_code_dir }} pyxserver_wsgi:application
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