Commit e427e7c4 by Max Rothman

OPS-1648: Write presupervisor/supervisor systemd config

parent 129328fc
......@@ -46,3 +46,36 @@ supervisor_version: 3.2.3
supervisor_pip_pkgs:
- boto=="{{ common_boto_version }}"
- python-simple-hipchat
supervisor_spec:
- service: edxapp
python: python.edxapp
code: "{{ edxapp_code_dir | default(None) }}"
env: "{{ edxapp_app_dir | default(None) }}/edxapp_env"
- service: xqueue
python: python.xqueue
code: "{{ xqueue_code_dir | default(None) }}"
- service: ecommerce
python: python.ecommerce
code: "{{ ecommerce_code_dir | default(None) }}"
env: "{{ ecommerce_home | default(None) }}/ecommerce_env"
- service: insights
python: python.insights
code: "{{ insights_code_dir | default(None) }}"
env: "{{ insights_home | default(None) }}/insights_env"
- service: analytics_api
python: python.analytics_api
code: "{{ analytics_api_code_dir | default(None) }}"
env: "{{ analytics_api_home | default(None) }}/analytics_api_env"
- service: programs
python: python.programs
code: "{{ programs_code_dir | default(None) }}"
env: "{{ programs_home | default(None) }}/programs_env"
- service: credentials
python: python.credentials
code: "{{ credentials_code_dir | default(None) }}"
env: "{{ credentials_home | default(None) }}/credentials_env"
- service: discovery
python: python.discovery
code: "{{ discovery_code_dir | default(None) }}"
env: "{{ discovery_home | default(None) }}/discovery_env"
......@@ -61,7 +61,7 @@
tags:
- install
- install:base
- name: Create supervisor and service user accessible directories
file:
path: "{{ item }}"
......@@ -121,6 +121,19 @@
dest: "/etc/init/{{ supervisor_service }}.conf"
owner: root
group: root
when: ansible_distribution_major_version < 16
tags:
- install
- install:base
# NB: with systemd, pre_supervisor is a pre-task for supervisor, not a separate service
- name: Create supervisor systemd job
template:
src: "etc/init/supervisor-systemd.service.j2"
dest: "/etc/systemd/system/{{ supervisor_service }}.service"
owner: root
group: root
when: ansible_distribution_major_version >= 16
tags:
- install
- install:base
......@@ -134,7 +147,9 @@
dest: "/etc/init/pre_supervisor.conf"
owner: root
group: root
when: supervisor_service == "supervisor" and disable_edx_services and not devstack
when: >
supervisor_service == "supervisor" and disable_edx_services and not devstack
and ansible_distribution_major_version < 16
tags:
- to-remove
- aws-specfic
......@@ -198,6 +213,15 @@
- install
- install:configuration
- name: Enable supervisor to start on boot
service:
name: "{{ supervisor_service }}.service"
enabled: yes
when: ansible_distribution_major_version >= 16
tags:
- install
- install:base
- name: Start supervisor
service:
name: "{{ supervisor_service }}"
......
[Unit]
Description=supervisord - Supervisor process control system
Documentation=http://supervisord.org
After=network.target
[Service]
{% if disable_edx_services and not devstack -%}
# Run pre_supervisor
ExecStartPre={{ supervisor_venv_dir }}/bin/python {{ supervisor_app_dir }}/pre_supervisor_checks.py \
{% if SUPERVISOR_HIPCHAT_API_KEY is defined -%}
--hipchat-api-key {{ SUPERVISOR_HIPCHAT_API_KEY }} --hipchat-room {{ SUPERVISOR_HIPCHAT_ROOM }} \
{% endif -%}
{%- for item in supervisor_spec -%}
{%- if item.code -%}
{%- set name = item.service.replace('_', '-') -%}
--{{ name }}-python {{ COMMON_BIN_DIR }}/{{ item.python }} --{{ name }}-code-dir {{ item.code }}
{%- if item.env is defined %} --{{ name }}-env {{ item.env }}{% endif %} \
{% endif %}
{%- endfor -%}
--available={{ supervisor_available_dir }} --enabled={{ supervisor_cfg_dir }}
{% endif %}
# User will be applied only to ExecStart, not other commands (i.e. ExecStartPre)
# This is needed because pre_supervisor needs to write to supervisor/conf.d, which
# supervisor_service_user does not have permission to do.
PermissionsStartOnly=true
User={{ supervisor_service_user }}
Type=forking
TimeoutStartSec=432000
ExecStart={{ supervisor_venv_dir }}/bin/supervisord --configuration {{ supervisor_cfg }}
ExecReload={{ supervisor_venv_dir }}/bin/supervisorctl reload
ExecStop={{ supervisor_venv_dir }}/bin/supervisorctl shutdown
[Install]
WantedBy=multi-user.target
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