Skip to content

Commit

Permalink
Merge pull request #132 from galaxyproject/systemd
Browse files Browse the repository at this point in the history
Add systemd, github actions support
  • Loading branch information
hexylena committed Jun 3, 2021
2 parents 528caf4 + 1bc43fd commit 717029c
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 31 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,30 @@
name: Test the role

# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#example-using-a-list-of-events
on: [pull_request]

jobs:
setup:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- name: Install dependencies
run: |
sudo apt-get install git python3 python3-virtualenv
pip3 install 'ansible<2.10'
printf '[defaults]\nroles_path = ../\ninterpreter_python = /usr/bin/python3' > ansible.cfg
- name: Run Test
run: |
export ANSIBLE_STDOUT_CALLBACK=yaml
ansible-playbook -i "localhost, " -c local tests/test_playbook.yml
systemctl status galaxy || true
journalctl -u galaxy
sleep 10
systemctl status galaxy
journalctl -u galaxy
sleep 10
curl http://127.0.0.1:8080/api/version
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

17 changes: 17 additions & 0 deletions defaults/main.yml
Expand Up @@ -19,6 +19,9 @@ galaxy_fetch_dependencies: yes
galaxy_build_client: yes
galaxy_manage_errordocs: no
galaxy_backup_configfiles: yes
galaxy_manage_systemd: no # For Galaxy
galaxy_manage_systemd_reports: no # For Reports


# Control whether to output verbose task diffs (e.g. when performing a git update) when running Ansible with --diff.
# Only suppresses diff on tasks that are likely to be verbose, not all tasks
Expand Down Expand Up @@ -274,3 +277,17 @@ galaxy_client_build_steps:
- stageLibs
- plugins


# systemd options
galaxy_restart_handler_name: "{{ 'galaxy mule restart' if (galaxy_systemd.mode == 'mule' and galaxy_manage_systemd) else 'default restart galaxy handler' }}"
galaxy_systemd:
env: "" #Any extra env vars
mode: mule
memory_limit:
mule: 16
reports: 5
#workflow: 5
#zergpool: 8
#zergling: 16
#handler: 5
stats: 4001 # Port for stats to listen on.
14 changes: 14 additions & 0 deletions handlers/main.yml
Expand Up @@ -13,3 +13,17 @@
subject: "Galaxy instance {{ galaxy_instance_hostname | default( inventory_hostname ) }} is at commit {{ galaxy_commit_id }}"
body: " "
when: galaxy_admin_email_to is defined

- name: daemon reload
systemd:
daemon_reload: yes

- name: galaxy mule start
systemd:
name: galaxy.service
state: started

- name: galaxy mule restart
systemd:
name: galaxy.service
state: restarted
2 changes: 1 addition & 1 deletion tasks/clone.yml
Expand Up @@ -15,7 +15,7 @@
diff: "{{ galaxy_diff_mode_verbose }}"
register: __galaxy_git_update_result
notify:
- "{{ galaxy_restart_handler_name | default('default restart galaxy handler') }}"
- "{{ galaxy_restart_handler_name }}"
- email administrator with commit id

- name: Report Galaxy version change
Expand Down
27 changes: 27 additions & 0 deletions tasks/main.yml
Expand Up @@ -120,3 +120,30 @@
when: galaxy_manage_errordocs
tags:
- galaxy_manage_errordocs

#- name: Include systemd unit setup tasks (Zerg Mode)
#include_tasks:
#file: systemd-zerg.yml
#apply:
#tags: galaxy_manage_systemd
#when: galaxy_manage_systemd and galaxy_systemd.mode == "zerg"
#tags:
#- galaxy_manage_systemd

- name: Include systemd unit setup tasks (Mules)
include_tasks:
file: systemd-mule.yml
apply:
tags: galaxy_manage_systemd
when: galaxy_manage_systemd and galaxy_systemd.mode == "mule"
tags:
- galaxy_manage_systemd

- name: Include systemd unit setup tasks (Reports)
include_tasks:
file: systemd-reports.yml
apply:
tags: galaxy_manage_systemd_reports
when: galaxy_manage_systemd_reports
tags:
- galaxy_manage_systemd_reports
6 changes: 3 additions & 3 deletions tasks/static_setup.yml
Expand Up @@ -15,7 +15,7 @@
backup: "{{ galaxy_backup_configfiles }}"
with_items: "{{ galaxy_config_files }}"
notify:
- "{{ galaxy_restart_handler_name | default('default restart galaxy handler') }}"
- "{{ galaxy_restart_handler_name }}"

- name: Install additional Galaxy config files (template)
template:
Expand All @@ -24,7 +24,7 @@
backup: "{{ galaxy_backup_configfiles }}"
with_items: "{{ galaxy_config_templates }}"
notify:
- "{{ galaxy_restart_handler_name | default('default restart galaxy handler') }}"
- "{{ galaxy_restart_handler_name }}"

- name: Install local tools
copy:
Expand Down Expand Up @@ -78,7 +78,7 @@
dest: "{{ galaxy_config_file }}"
backup: "{{ galaxy_backup_configfiles }}"
notify:
- "{{ galaxy_restart_handler_name | default('default restart galaxy handler') }}"
- "{{ galaxy_restart_handler_name }}"

remote_user: "{{ galaxy_remote_users.privsep | default(__galaxy_remote_user) }}"
become: "{{ true if galaxy_become_users.privsep is defined else __galaxy_become }}"
Expand Down
24 changes: 24 additions & 0 deletions tasks/systemd-mule.yml
@@ -0,0 +1,24 @@
---

- name: Manage Paths
block:

- name: Deploy Galaxy Unit
template:
owner: root
group: root
mode: 0644
src: systemd/galaxy.service.j2
dest: /etc/systemd/system/galaxy.service
notify:
- daemon reload
- galaxy mule restart

- name: Enable Galaxy Unit
systemd:
name: galaxy.service
enabled: yes

remote_user: "{{ galaxy_remote_users.root | default(__galaxy_remote_user) }}"
become: "{{ true if galaxy_become_users.root is defined else __galaxy_become }}"
become_user: "{{ galaxy_become_users.root | default(__galaxy_become_user) }}"
23 changes: 23 additions & 0 deletions tasks/systemd-reports.yml
@@ -0,0 +1,23 @@
---

- name: Manage Paths
block:

- name: Deploy Galaxy Reports unit
template:
owner: root
group: root
mode: 0644
src: systemd/galaxy-reports.service.j2
dest: /etc/systemd/system/galaxy-reports.service
notify: daemon reload

- name: Enable reports and ensure it is running
systemd:
name: galaxy-reports.service
enabled: yes
state: started

remote_user: "{{ galaxy_remote_users.root | default(__galaxy_remote_user) }}"
become: "{{ true if galaxy_become_users.root is defined else __galaxy_become }}"
become_user: "{{ galaxy_become_users.root | default(__galaxy_become_user) }}"
23 changes: 23 additions & 0 deletions templates/systemd/galaxy-reports.service.j2
@@ -0,0 +1,23 @@
[Unit]
Description=Galaxy Reports
After=network.target
After=time-sync.target

[Service]
UMask=022
Type=simple
User={{ __galaxy_user_name }}
Group={{ __galaxy_user_group }}
WorkingDirectory={{ galaxy_server_dir }}
TimeoutStartSec=10
ExecStart={{ galaxy_venv_dir }}/bin/uwsgi {{ '--yaml' if galaxy_config_style in ('yaml', 'yml') else '--ini' }} {{ galaxy_reports_path }} --stats 127.0.0.1:4030
Environment=HOME={{ galaxy_root }} VIRTUAL_ENV={{ galaxy_venv_dir }} PATH={{ galaxy_venv_dir }}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin DOCUTILSCONFIG= PYTHONPATH={{ galaxy_dynamic_job_rules_dir }} {{ galaxy_systemd.env }}
MemoryLimit={{ galaxy_systemd.memory_limit.reports }}G
Restart=always

MemoryAccounting=yes
CPUAccounting=yes
BlockIOAccounting=yes

[Install]
WantedBy=multi-user.target
24 changes: 24 additions & 0 deletions templates/systemd/galaxy.service.j2
@@ -0,0 +1,24 @@
[Unit]
Description=Galaxy
After=network.target
After=time-sync.target

[Service]
UMask=022
Type=simple
User={{ __galaxy_user_name }}
Group={{ __galaxy_user_group }}
WorkingDirectory={{ galaxy_server_dir }}
TimeoutStartSec=10
ExecStart={{ galaxy_venv_dir }}/bin/uwsgi {{ '--yaml' if galaxy_config_style in ('yaml', 'yml') else '--ini' }} {{ galaxy_config_file }} {% if galaxy_systemd.stats %}--stats 127.0.0.1:{{ galaxy_systemd.stats }}{% endif %}

Environment=HOME={{ galaxy_root }} VIRTUAL_ENV={{ galaxy_venv_dir }} PATH={{ galaxy_venv_dir }}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin DOCUTILSCONFIG= PYTHONPATH={{ galaxy_dynamic_job_rules_dir }} {{ galaxy_systemd.env }}
MemoryLimit={{ galaxy_systemd.memory_limit.mule }}G
Restart=always

MemoryAccounting=yes
CPUAccounting=yes
BlockIOAccounting=yes

[Install]
WantedBy=multi-user.target
8 changes: 5 additions & 3 deletions tests/test_playbook.yml
Expand Up @@ -2,16 +2,17 @@
# Travis CI test playbook

- hosts: localhost
gather_facts: False
connection: local
remote_user: travis
become: true
remote_user: runner
vars:
galaxy_commit_id: release_19.09
galaxy_commit_id: release_21.01
galaxy_create_user: yes
galaxy_manage_paths: yes
galaxy_manage_clone: yes
galaxy_manage_download: no
galaxy_manage_existing: no
galaxy_manage_systemd: yes
galaxy_config_style: yaml
galaxy_layout: root-dir
galaxy_root: /srv/galaxy
Expand All @@ -26,5 +27,6 @@
ansible_user_id: "{{ lookup('env', 'USER') }}"
ansible_env:
PATH: "{{ lookup('env', 'PATH') }}"
pip_virtualenv_command: /usr/bin/python3 -m virtualenv
roles:
- role: ansible-galaxy

0 comments on commit 717029c

Please sign in to comment.