Commit 65dd9699 by Feanil Patel

Merge pull request #164 from edx/feanil/ansible_workers_rebase

Feanil/ansible workers rebase
parents a6c16cf7 b88f340a
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
- common - common
- nginx - nginx
- edxapp - edxapp
- { role: 'edxapp', celery_worker: True }
- hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_xserver - hosts: tag_aws_cloudformation_stack-name_feanilpractice:&tag_group_xserver
sudo: True sudo: True
......
...@@ -26,3 +26,5 @@ ...@@ -26,3 +26,5 @@
- nginx - nginx
- edxlocal - edxlocal
- edxapp - edxapp
- rabbitmq
- { role: 'edxapp', celery_worker: True }
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
- update - update
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=cms - include: ../../nginx/tasks/nginx_site.yml state=link site_name=cms
when: celery_worker is not defined
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=cms-backend - include: ../../nginx/tasks/nginx_site.yml state=link site_name=cms-backend
when: celery_worker is not defined
- name: Create CMS log target directory - name: Create CMS log target directory
file: path={{log_base_dir}}/cms state=directory owner=syslog group=adm mode=2770 file: path={{log_base_dir}}/cms state=directory owner=syslog group=adm mode=2770
...@@ -29,5 +31,9 @@ ...@@ -29,5 +31,9 @@
- logging - logging
- update - update
# Creates LMS upstart file # Creates CMS upstart file
- include: upstart.yml service_variant=cms - include: upstart.yml basename=cms
when: celery_worker is not defined
- include: upstart.yml basename=edx-worker-cms
when: celery_worker is defined
# Gather lms assets using rake if possible
- name: gather lms static assets with rake
shell: executable=/bin/bash chdir={{ edx_platform_code_dir }} SERVICE_VARIANT={{ lms_variant }} rake lms:gather_assets:aws
when: grep_gather_assets.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- lms
- lms-preview
- lms-xml
- deploy
# Gather lms assets using django if necessary(When rake doesn't know how)
- name: gather lms static assets with django
shell: SERVICE_VARIANT={{ lms_variant }} django-admin.py collectstatic --pythonpath={{ edx_platform_code_dir }} --settings=lms.envs.aws --noinput --verbosity=0
when: grep_gather_assets.rc != 0 and check_lms_collect_static.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- lms
- lms-preview
- lms-xml
- deploy
# Gather cms assets using rake if possible
- name: gather cms static assets with rake
# script: gather_assets.sh
shell: executable=/bin/bash chdir={{ edx_platform_code_dir }} SERVICE_VARIANT={{ cms_variant }} rake cms:gather_assets:aws
when: grep_gather_assets.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- cms
- deploy
- name: gather cms static assets with django
shell: SERVICE_VARIANT={{ cms_variant }} django-admin.py collectstatic --pythonpath={{ edx_platform_code_dir }} --settings=lms.envs.aws --noinput --verbosity=0
when: grep_gather_assets.rc != 0 and check_cms_collect_static.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- cms
- deploy
- name: update cms templates
shell: SERVICE_VARIANT={{ cms_variant }} django-admin.py update_templates --pythonpath={{ edx_platform_code_dir }} --settings=cms.envs.aws
when: check_cms_update_templates.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- cms
- deploy
# Add failure checks for if no static assets were deployed.
- name: lms asset static failure check
shell: /bin/false
when: grep_gather_assets.rc != 0 and check_lms_collect_static.rc != 0
tags:
- lms
- lms-preview
- lms-xml
- deploy
- name: cms asset static failure check
shell: /bin/false
when: grep_gather_assets.rc != 0 and check_cms_collect_static.rc != 0
tags:
- cms
- deploy
# Stop all services. # Stop all services.
- name: stop edxapp services - name: stop edxapp services
service: name=edxapp state=stopped service: name=edxapp state=stopped
when: celery_worker is not defined
tags: tags:
- lms - lms
- lms-xml - lms-xml
...@@ -8,6 +9,12 @@ ...@@ -8,6 +9,12 @@
- cms - cms
- deploy - deploy
- name: stop edx workers
service: name=edx-workers state=stopped
when: celery_worker is defined
tags:
- deploy
# Do A Checkout # Do A Checkout
- name: git checkout edx-platform repo into $app_base_dir - name: git checkout edx-platform repo into $app_base_dir
git: dest={{edx_platform_code_dir}} repo={{lms_source_repo}} version={{lms_version}} git: dest={{edx_platform_code_dir}} repo={{lms_source_repo}} version={{lms_version}}
...@@ -169,91 +176,8 @@ ...@@ -169,91 +176,8 @@
- cms - cms
- deploy - deploy
# Gather lms assets using rake if possible - include: collect_static.yml
- name: gather lms static assets with rake when: celery_worker is not defined
shell: executable=/bin/bash chdir={{ edx_platform_code_dir }} SERVICE_VARIANT={{ lms_variant }} rake lms:gather_assets:aws
when: grep_gather_assets.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- lms
- lms-preview
- lms-xml
- deploy
# Gather lms assets using django if necessary(When rake doesn't know how)
- name: gather lms static assets with django
shell: SERVICE_VARIANT={{ lms_variant }} django-admin.py collectstatic --pythonpath={{ edx_platform_code_dir }} --settings=lms.envs.aws --noinput --verbosity=0
when: grep_gather_assets.rc != 0 and check_lms_collect_static.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- lms
- lms-preview
- lms-xml
- deploy
# Gather cms assets using rake if possible
- name: gather cms static assets with rake
# script: gather_assets.sh
shell: executable=/bin/bash chdir={{ edx_platform_code_dir }} SERVICE_VARIANT={{ cms_variant }} rake cms:gather_assets:aws
when: grep_gather_assets.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- cms
- deploy
- name: gather cms static assets with django
shell: SERVICE_VARIANT={{ cms_variant }} django-admin.py collectstatic --pythonpath={{ edx_platform_code_dir }} --settings=lms.envs.aws --noinput --verbosity=0
when: grep_gather_assets.rc != 0 and check_cms_collect_static.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- cms
- deploy
- name: update cms templates
shell: SERVICE_VARIANT={{ cms_variant }} django-admin.py update_templates --pythonpath={{ edx_platform_code_dir }} --settings=cms.envs.aws
when: check_cms_update_templates.rc == 0
notify:
- restart edxapp
sudo: yes
sudo_user: www-data
environment: "{{ deploy_environment }}"
tags:
- cms
- deploy
# Add failure checks for if no static assets were deployed.
- name: lms asset static failure check
shell: /bin/false
when: grep_gather_assets.rc != 0 and check_lms_collect_static.rc != 0
tags:
- lms
- lms-preview
- lms-xml
- deploy
- name: cms asset static failure check
shell: /bin/false
when: grep_gather_assets.rc != 0 and check_cms_collect_static.rc != 0
tags:
- cms
- deploy
# https://code.launchpad.net/~wligtenberg/django-openid-auth/mysql_fix/+merge/22726 # https://code.launchpad.net/~wligtenberg/django-openid-auth/mysql_fix/+merge/22726
# This is necessary for the local mysql5.5, not sure if this fix will ever get merged # This is necessary for the local mysql5.5, not sure if this fix will ever get merged
...@@ -275,9 +199,16 @@ ...@@ -275,9 +199,16 @@
- name: restart edxapp - name: restart edxapp
service: name=edxapp state=restarted service: name=edxapp state=restarted
when: celery_worker is not defined
tags: tags:
- lms - lms
- lms-xml - lms-xml
- lms-preview - lms-preview
- cms - cms
- deploy - deploy
- name: restart workers
service: name=edx-workers state=restarted
when: celery_worker is defined
tags:
- deploy
...@@ -24,8 +24,10 @@ ...@@ -24,8 +24,10 @@
- update - update
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-preview - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-preview
when: celery_worker is not defined
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-preview-backend - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-preview-backend
when: celery_worker is not defined
# Creates LMS Preview upstart file # Creates LMS Preview upstart file
- include: upstart.yml service_variant=lms-preview - include: upstart.yml basename=lms-preview
...@@ -26,8 +26,14 @@ ...@@ -26,8 +26,14 @@
- update - update
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-xml - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-xml
when: celery_worker is not defined
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-xml-backend - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-xml-backend
when: celery_worker is not defined
# Creates upstart file # Creates upstart file
- include: upstart.yml service_variant=lms-xml - include: upstart.yml basename=lms-xml
when: celery_worker is not defined
- include: upstart.yml basename=edx-worker-lms-xml
when: celery_worker is defined
...@@ -22,6 +22,14 @@ ...@@ -22,6 +22,14 @@
- update - update
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms
when: celery_worker is not defined
- include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-backend - include: ../../nginx/tasks/nginx_site.yml state=link site_name=lms-backend
when: celery_worker is not defined
# Creates LMS upstart file # Creates LMS upstart file
- include: upstart.yml service_variant=lms - include: upstart.yml basename=lms
when: celery_worker is not defined
- include: upstart.yml basename=edx-worker-lms
when: celery_worker is defined
...@@ -48,11 +48,19 @@ ...@@ -48,11 +48,19 @@
- name: creating edxapp upstart script - name: creating edxapp upstart script
sudo: True sudo: True
template: src=edxapp.conf.j2 dest=/etc/init/edxapp.conf owner=root group=root template: src=edxapp.conf.j2 dest=/etc/init/edxapp.conf owner=root group=root
when: "celery_worker is not defined"
tags: tags:
- upstart - upstart
- gunicorn - gunicorn
- update - update
- name: create edx-workers upstart script
template: src=edx-workers.conf.j2 dest=/etc/init/edx-workers.conf owner=root group=root
when: "celery_worker is defined"
tags:
- upstart
- update
- include: npm.yml - include: npm.yml
- include: ruby.yml - include: ruby.yml
- include: deploy.yml - include: deploy.yml
# write the gunicorn upstart script for {{ service_variant }} # write the gunicorn upstart script for {{ service_variant }}
- name: writing {{ service_variant }} upstart script to /etc/init - name: writing {{ basename }} upstart script to /etc/init
sudo: True sudo: True
template: src={{ service_variant }}.conf.j2 dest=/etc/init/{{ service_variant }}.conf owner=root group=root template: src={{ basename }}.conf.j2 dest=/etc/init/{{ basename }}.conf owner=root group=root
tags: tags:
- upstart - upstart
- gunicorn - gunicorn
......
# gunicorn # gunicorn
# Templated and placed by ansible from jinja2 source # Templated and placed by ansible from jinja2 source
description "cms gunicorn"
description "gunicorn server" # CMS Upstart Script
author "Calen Pennington <cpennington@mitx.mit.edu>"
start on started edxapp start on started edxapp
stop on stopped edxapp stop on stopped edxapp
......
# gunicorn
# Templated and placed by ansible from jinja2 source
# CMS Celery Worker Upstart Script
description "cms celery worker"
stop on stopping edx-workers
respawn
instance edx.${SERVICE_VARIANT}.core.${QUEUE}
#env NEW_RELIC_CONFIG_FILE=/opt/wwc/newrelic.ini
#env NEWRELIC={{venv_dir}}/bin/newrelic-admin
env CONCURRENCY=${CONCURRENCY}
env LOGLEVEL=info
env DJANGO_SETTINGS_MODULE=cms.envs.aws
env PYTHONPATH={{edx_platform_code_dir}}
env SERVICE_VARIANT=${SERVICE_VARIANT}
setuid www-data
chdir {{edx_platform_code_dir}}
exec {{venv_dir}}/bin/django-admin.py celery worker --settings=$DJANGO_SETTINGS_MODULE --pythonpath=$PYTHONPATH --loglevel=$LOGLEVEL --queues=edx.${SERVICE_VARIANT}.core.${QUEUE} --hostname=edx.${SERVICE_VARIANT}.core.${QUEUE}.`hostname` --concurrency=$CONCURRENCY
# gunicorn
# Templated and placed by ansible from jinja2 source
# lms-xml Celery Worker Upstart Script
description "cms celery worker"
stop on stopping edx-workers
respawn
instance edx.${SERVICE_VARIANT}.core.${QUEUE}
#env NEW_RELIC_CONFIG_FILE=/opt/wwc/newrelic.ini
#env NEWRELIC={{venv_dir}}/bin/newrelic-admin
env CONCURRENCY=${CONCURRENCY}
env LOGLEVEL=info
env DJANGO_SETTINGS_MODULE=lms.envs.aws
env PYTHONPATH={{edx_platform_code_dir}}
env SERVICE_VARIANT=${SERVICE_VARIANT}
setuid www-data
chdir {{edx_platform_code_dir}}
exec {{venv_dir}}/bin/django-admin.py celery worker --settings=$DJANGO_SETTINGS_MODULE --pythonpath=$PYTHONPATH --loglevel=$LOGLEVEL --queues=edx.${SERVICE_VARIANT}.core.${QUEUE} --hostname=edx.${SERVICE_VARIANT}.core.${QUEUE}.`hostname` --concurrency=$CONCURRENCY
# gunicorn
# Templated and placed by ansible from jinja2 source
# CMS Celery Worker Upstart Script
description "lms celery worker"
stop on stopping edx-workers
respawn
instance edx.${SERVICE_VARIANT}.core.${QUEUE}
#env NEW_RELIC_CONFIG_FILE=/opt/wwc/newrelic.ini
#env NEWRELIC={{venv_dir}}/bin/newrelic-admin
env CONCURRENCY=${CONCURRENCY}
env LOGLEVEL=info
env DJANGO_SETTINGS_MODULE=lms.envs.aws
env PYTHONPATH={{edx_platform_code_dir}}
env SERVICE_VARIANT=${SERVICE_VARIANT}
setuid www-data
chdir {{edx_platform_code_dir}}
exec {{venv_dir}}/bin/django-admin.py celery worker --settings=$DJANGO_SETTINGS_MODULE --pythonpath=$PYTHONPATH --loglevel=$LOGLEVEL --queues=edx.${SERVICE_VARIANT}.core.${QUEUE} --hostname=edx.${SERVICE_VARIANT}.core.${QUEUE}.`hostname` --concurrency=$CONCURRENCY
# edx workers
# managed by puppet or ansible
description "start edX app workers"
start on runlevel [2345]
stop on runlevel [!2345]
pre-start script
{% if 'cms' in service_variants_enabled %}
start edx-worker-cms QUEUE=low CONCURRENCY=1 SERVICE_VARIANT=cms
start edx-worker-cms QUEUE=default CONCURRENCY=3 SERVICE_VARIANT=cms
start edx-worker-cms QUEUE=high CONCURRENCY=4 SERVICE_VARIANT=cms
{% endif %}
{% if 'lms' in service_variants_enabled %}
start edx-worker-lms QUEUE=low CONCURRENCY=1 SERVICE_VARIANT=lms
start edx-worker-lms QUEUE=default CONCURRENCY=3 SERVICE_VARIANT=lms
start edx-worker-lms QUEUE=high CONCURRENCY=4 SERVICE_VARIANT=lms
{% endif %}
{% if 'lms-xml' in service_variants_enabled %}
start edx-worker-lms-xml QUEUE=low CONCURRENCY=1 SERVICE_VARIANT=lms-xml
start edx-worker-lms-xml QUEUE=default CONCURRENCY=3 SERVICE_VARIANT=lms-xml
start edx-worker-lms-xml QUEUE=high CONCURRENCY=4 SERVICE_VARIANT=lms-xml
{% endif %}
end script
# gunicorn # gunicorn
# Templated and placed by ansible from jinja2 source
description "gunicorn server" description "lms-xml gunicorn server"
author "Calen Pennington <cpennington@mitx.mit.edu>"
start on started edxapp start on started edxapp
stop on stopped edxapp stop on stopped edxapp
...@@ -39,4 +38,3 @@ post-start script ...@@ -39,4 +38,3 @@ post-start script
fi fi
done done
end script end script
# gunicorn # gunicorn
# Templated and placed by ansible from jinja2 source
description "gunicorn server"
author "Calen Pennington <cpennington@mitx.mit.edu>"
start on started edxapp start on started edxapp
stop on stopped edxapp stop on stopped edxapp
...@@ -39,4 +36,3 @@ post-start script ...@@ -39,4 +36,3 @@ post-start script
fi fi
done done
end script end script
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