Commit 45fc3a17 by jarv

Merge pull request #38 from edx/jbau/upstart

role for upstart tasks, parameterized in the style the nginx role
parents a9d33e94 7cdae1c4
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
roles: roles:
- common - common
- nginx - nginx
- gunicorn
- lms - lms
- ruby - ruby
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
roles: roles:
- common - common
- nginx - nginx
- gunicorn
- lms - lms
- ruby - ruby
---
- name: pip install gunicorn
pip: name=gunicorn virtualenv="{{venv_dir}}" state=present
tags:
- gunicorn
#write the gunicorn upstart script for {{ service_variant }}
- name: writing ${service_variant} upstart script to /etc/init
sudo: True
template: src={{ item }} dest=/etc/init/${service_variant}.conf owner=root group=root
first_available_file:
- "{{ local_dir }}/gunicorn/templates/{{ service_variant }}.conf.j2"
# seems like paths in first_available_file must be relative to the playbooks dir
- "roles/gunicorn/templates/{{ service_variant }}.conf.j2"
tags:
- upstart
- gunicorn
# gunicorn
description "gunicorn server"
author "Calen Pennington <cpennington@mitx.mit.edu>"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 3 30
env PID=/var/tmp/lms.pid
#env NEW_RELIC_CONFIG_FILE=${app_base_dir}/opt/wwc/newrelic.ini
#env NEWRELIC=${app_base_dir}/bin/newrelic-admin
env WORKERS=${lms_num_workers}
env PORT=8000
env LANG=en_US.UTF-8
env DJANGO_SETTINGS_MODULE=lms.envs.aws
env SERVICE_VARIANT="lms"
chdir ${app_base_dir}/mitx
setuid www-data
exec ${venv_dir}/bin/gunicorn --preload -b 127.0.0.1:$PORT -w $WORKERS --timeout=300 --pythonpath=${app_base_dir}/mitx lms.wsgi
post-start script
while true
do
if $(curl -s -i localhost:$PORT/heartbeat | egrep -q '200 OK'); then
break;
else
sleep 1;
fi
done
end script
---
lms_num_workers: 1
\ No newline at end of file
...@@ -8,16 +8,19 @@ ...@@ -8,16 +8,19 @@
sudo: True sudo: True
tags: tags:
- lms - lms
- lms-env
- name: create lms auth file - name: create lms auth file
template: src=auth.json.j2 dest=$app_base_dir/lms.auth.json template: src=auth.json.j2 dest=$app_base_dir/lms.auth.json
sudo: True sudo: True
tags: tags:
- lms - lms
- lms-env
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-backend - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-backend
# Install ssh keys for ubuntu account to be able to check out from mitx # Install ssh keys for ubuntu account to be able to check out from mitx
# Temprory behavior, not needed after June 1. Perhaps still useful as a recipe. # Temprory behavior, not needed after June 1. Perhaps still useful as a recipe.
# {{ secure_dir }} is relative to the top-level playbooks dir so there is some # {{ secure_dir }} is relative to the top-level playbooks dir so there is some
...@@ -111,3 +114,6 @@ ...@@ -111,3 +114,6 @@
tags: tags:
- lms - lms
- cms - cms
# Creates LMS upstart file
- include: ../../gunicorn/tasks/upstart.yml service_variant=lms
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
tags: tags:
- nginx - nginx
- lms - lms
- nginx-env
- name: Creating nginx config link {{ site_name }} - name: Creating nginx config link {{ site_name }}
sudo: True sudo: True
...@@ -19,3 +20,4 @@ ...@@ -19,3 +20,4 @@
tags: tags:
- nginx - nginx
- lms - lms
- nginx-env
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