Unverified Commit bb70c002 by Fred Smith Committed by GitHub

Merge pull request #4561 from edx/derf/update_nr_display_name_to_instanceid_on_aws

update nr display name to instanceid on aws
parents 5a065778 02874323
......@@ -12,6 +12,11 @@
{% if COMMON_ENABLE_NEWRELIC_APP %}
export NEW_RELIC_APP_NAME="{{ edx_django_service_newrelic_appname }}"
if command -v ec2metadata >/dev/null 2>&1; then
INSTANCEID=$(ec2metadata --instance-id);
HOSTNAME=$(hostname)
export NEW_RELIC_PROCESS_HOST_DISPLAY_NAME="$HOSTNAME-$INSTANCEID"
fi
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% endif -%}
......
......@@ -310,6 +310,21 @@
- install
- install:code
- name: "create service wrapper scripts - {{item}}"
template:
dest: "{{ edxapp_app_dir }}/{{item}}"
src: "edx/app/edxapp/{{item}}.j2"
owner: "{{ edxapp_user }}"
group: "{{ common_web_group }}"
mode: "og+rx"
with_items:
- "lms.sh"
- "cms.sh"
- "worker.sh"
tags:
- install
- install:configuration
# creates the supervisor jobs for the
# service variants configured, runs
# gather_assets and db migrations
......
......@@ -19,7 +19,7 @@
# write the supervisor scripts for the service variants
- name: "writing {{ item }} supervisor script"
template:
src: "{{ item }}.conf.j2"
src: "edx/app/supervisor/conf.d.available/{{ item }}.conf.j2"
dest: "{{ supervisor_available_dir }}/{{ item }}.conf"
owner: "{{ supervisor_user }}"
group: "{{ supervisor_user }}"
......@@ -33,7 +33,7 @@
# write the supervisor script for edxapp and celery workers
- name: writing edxapp and celery supervisor scripts
template:
src: "{{ item }}.j2"
src: "edx/app/supervisor/conf.d.available/{{ item }}.j2"
dest: "{{ supervisor_available_dir }}/{{ item }}"
owner: "{{ supervisor_user }}"
group: "{{ supervisor_user }}"
......
#!/usr/bin/env bash
# {{ ansible_managed }}
{% set edxapp_venv_bin = edxapp_venv_dir + "/bin" %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + edxapp_venv_bin + '/gunicorn' %}
export NEW_RELIC_APP_NAME="{{ EDXAPP_NEWRELIC_CMS_APPNAME }}"
export NEW_RELIC_CONFIG_FILE="{{ edxapp_app_dir }}/newrelic.ini"
if command -v ec2metadata >/dev/null 2>&1; then
INSTANCEID=$(ec2metadata --instance-id);
HOSTNAME=$(hostname)
export NEW_RELIC_PROCESS_HOST_DISPLAY_NAME="$HOSTNAME-$INSTANCEID"
fi
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% else %}
{% set executable = edxapp_venv_bin + '/gunicorn' %}
{% endif %}
export PORT="{{ edxapp_cms_gunicorn_port }}"
export ADDRESS="{{ edxapp_cms_gunicorn_host }}"
export LANG="{{ EDXAPP_LANG }}"
export DJANGO_SETTINGS_MODULE="{{ EDXAPP_CMS_ENV }}"
export SERVICE_VARIANT="cms"
export PATH="{{ edxapp_deploy_path }}"
export BOTO_CONFIG="{{ edxapp_app_dir }}/.boto"
source {{ edxapp_app_dir }}/edxapp_env
{{ executable }} -c {{ edxapp_app_dir }}/cms_gunicorn.py {{ EDXAPP_CMS_GUNICORN_EXTRA }} cms.wsgi
#!/usr/bin/env bash
# {{ ansible_managed }}
{% set edxapp_venv_bin = edxapp_venv_dir + "/bin" %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + edxapp_venv_bin + '/gunicorn' %}
export NEW_RELIC_APP_NAME="{{ EDXAPP_NEWRELIC_LMS_APPNAME }}"
export NEW_RELIC_CONFIG_FILE="{{ edxapp_app_dir }}/newrelic.ini"
if command -v ec2metadata >/dev/null 2>&1; then
INSTANCEID=$(ec2metadata --instance-id);
HOSTNAME=$(hostname)
export NEW_RELIC_PROCESS_HOST_DISPLAY_NAME="$HOSTNAME-$INSTANCEID"
fi
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% else %}
{% set executable = edxapp_venv_bin + '/gunicorn' %}
{% endif -%}
export PORT="{{ edxapp_lms_gunicorn_port }}"
export ADDRESS="{{ edxapp_lms_gunicorn_host }}"
export LANG="{{ EDXAPP_LANG }}"
export DJANGO_SETTINGS_MODULE="{{ EDXAPP_LMS_ENV }}"
export SERVICE_VARIANT="lms"
export PATH="{{ edxapp_deploy_path }}"
export BOTO_CONFIG="{{ edxapp_app_dir }}/.boto"
source {{ edxapp_app_dir }}/edxapp_env
{{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi
#!/usr/bin/env bash
# {{ ansible_managed }}
{% set edxapp_venv_bin = edxapp_venv_dir + "/bin" %}
{% if COMMON_ENABLE_NEWRELIC_APP %}
{% set executable = edxapp_venv_bin + '/newrelic-admin run-program ' + edxapp_venv_bin + '/python' %}
export NEW_RELIC_CONFIG_FILE="{{ edxapp_app_dir }}/newrelic.ini"
if command -v ec2metadata >/dev/null 2>&1; then
INSTANCEID=$(ec2metadata --instance-id);
HOSTNAME=$(hostname)
export NEW_RELIC_PROCESS_HOST_DISPLAY_NAME="$HOSTNAME-$INSTANCEID"
fi
{% else %}
{% set executable = edxapp_venv_bin + '/python' %}
{% endif %}
{{ executable }} {{ edxapp_code_dir }}/manage.py $@
[program:cms]
{% if COMMON_ENABLE_NEWRELIC_APP -%}
{% set executable = edxapp_venv_dir + '/bin/newrelic-admin run-program ' + edxapp_venv_dir + '/bin/gunicorn' -%}
{% else -%}
{% set executable = edxapp_venv_dir + '/bin/gunicorn' -%}
{% endif -%}
command={{ executable }} -c {{ edxapp_app_dir }}/cms_gunicorn.py {{ EDXAPP_CMS_GUNICORN_EXTRA }} cms.wsgi
command={{ edxapp_app_dir }}/cms.sh
user={{ common_web_user }}
directory={{ edxapp_code_dir }}
environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_CMS_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}PORT={{ edxapp_cms_gunicorn_port }},ADDRESS={{ edxapp_cms_gunicorn_host }},LANG={{ EDXAPP_LANG }},DJANGO_SETTINGS_MODULE={{ EDXAPP_CMS_ENV }},SERVICE_VARIANT="cms",BOTO_CONFIG="{{ edxapp_app_dir }}/.boto"
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log
killasgroup=true
......
[program:lms]
{% if COMMON_ENABLE_NEWRELIC_APP -%}
{% set executable = edxapp_venv_dir + '/bin/newrelic-admin run-program ' + edxapp_venv_dir + '/bin/gunicorn' -%}
{% else -%}
{% set executable = edxapp_venv_dir + '/bin/gunicorn' -%}
{% endif -%}
command={{ executable }} -c {{ edxapp_app_dir }}/lms_gunicorn.py lms.wsgi
command={{ edxapp_app_dir }}/lms.sh
user={{ common_web_user }}
directory={{ edxapp_code_dir }}
environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_LMS_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},NEW_RELIC_CONFIG_FILE={{ edxapp_app_dir }}/newrelic.ini,{% endif -%} PORT={{ edxapp_lms_gunicorn_port }},ADDRESS={{ edxapp_lms_gunicorn_host }},LANG={{ EDXAPP_LANG }},DJANGO_SETTINGS_MODULE={{ EDXAPP_LMS_ENV }},SERVICE_VARIANT="lms",PATH="{{ edxapp_deploy_path }}",BOTO_CONFIG="{{ edxapp_app_dir }}/.boto"
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log
killasgroup=true
......
{% for w in edxapp_workers %}
[program:{{ w.service_variant }}_{{ w.queue }}_{{ w.concurrency }}]
environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_WORKERS_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}CONCURRENCY={{ w.concurrency }},LOGLEVEL=info,DJANGO_SETTINGS_MODULE={{ worker_django_settings_module }},LANG={{ EDXAPP_LANG }},PYTHONPATH={{ edxapp_code_dir }},SERVICE_VARIANT={{ w.service_variant }},BOTO_CONFIG="{{ edxapp_app_dir }}/.boto"
environment={% if COMMON_ENABLE_NEWRELIC_APP %}NEW_RELIC_APP_NAME={{ EDXAPP_NEWRELIC_WORKERS_APPNAME }},NEW_RELIC_LICENSE_KEY={{ NEWRELIC_LICENSE_KEY }},{% endif -%}CONCURRENCY={{ w.concurrency }},LOGLEVEL=info,DJANGO_SETTINGS_MODULE={{ worker_django_settings_module }},LANG={{ EDXAPP_LANG }},PYTHONPATH={{ edxapp_code_dir }},SERVICE_VARIANT={{ w.service_variant }},BOTO_CONFIG="{{ edxapp_app_dir }}/.boto,"
user={{ common_web_user }}
directory={{ edxapp_code_dir }}
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log
command={{ edxapp_venv_dir + '/bin/newrelic-admin run-program ' if w.monitor and COMMON_ENABLE_NEWRELIC_APP else ''}}{{ edxapp_venv_bin }}/python {{ edxapp_code_dir }}/manage.py {{ w.service_variant }} --settings={{ worker_django_settings_module }} celery worker --loglevel=info --queues=edx.{{ w.service_variant }}.core.{{ w.queue }} --hostname=edx.{{ w.service_variant }}.core.{{ w.queue }}.%%h --concurrency={{ w.concurrency }} {{ '--maxtasksperchild ' + w.max_tasks_per_child|string if w.max_tasks_per_child is defined else '' }}
command={{ edxapp_app_dir }}/worker.sh {{ w.service_variant }} --settings={{ worker_django_settings_module }} celery worker --loglevel=info --queues=edx.{{ w.service_variant }}.core.{{ w.queue }} --hostname=edx.{{ w.service_variant }}.core.{{ w.queue }}.%%h --concurrency={{ w.concurrency }} {{ '--maxtasksperchild ' + w.max_tasks_per_child|string if w.max_tasks_per_child is defined else '' }}
killasgroup=true
stopwaitsecs={{ w.stopwaitsecs | default(EDXAPP_WORKER_DEFAULT_STOPWAITSECS) }}
; Set autorestart to `true`. The default value for autorestart is `unexpected`, but celery < 4.x will exit
......
#! /usr/bin/env bash
if command -v ec2metadata >/dev/null 2>&1; then
INSTANCEID=$(ec2metadata --instance-id);
HOSTNAME=$(hostname)
DISPLAY_NAME="$HOSTNAME-$INSTANCEID"
if [[ -f /etc/newrelic/nrsysmond.cfg ]]; then
sudo sed -i 's/^hostname=.*//g' /etc/newrelic/nrsysmond.cfg
echo "hostname=\"$DISPLAY_NAME\"" | sudo tee -a /etc/newrelic/nrsysmond.cfg
sudo service newrelic-sysmond restart
fi
if [[ -f /etc/newrelic-infra.yml ]]; then
sudo sed -i 's/^display_name: .*//g' /etc/newrelic-infra.yml
echo "display_name: \"$DISPLAY_NAME\"" | sudo tee -a /etc/newrelic-infra.yml
sudo service newrelic-infra restart
fi
fi
......@@ -81,6 +81,21 @@
- install:app-requirements
when: ansible_distribution == 'Amazon'
- name: Install newrelic display name script
copy:
src: "edx/bin/write_nr_display_name_config.sh"
dest: "/edx/bin/write_nr_display_name_config.sh"
owner: root
group: root
mode: u=rwx,g=r,o=r
- name: Run newrelic display name script on boot
lineinfile:
path: "/etc/rc.local"
line: "/edx/bin/write_nr_display_name_config.sh"
insertbefore: "exit 0"
mode: "u+x,g+x"
- name: Restart the infrastructure agent if the license key changes
service:
name: newrelic-infra
......
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