Skip to content

Commit

Permalink
Merge pull request #185 from galaxyproject/gravity-systemd
Browse files Browse the repository at this point in the history
Updates for systemd mode Gravity
  • Loading branch information
hexylena committed Apr 11, 2023
2 parents d16df3c + d5acc7f commit 898d006
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ galaxy_node_version_max: >-
# systemd options
#

__galaxy_gravity_pm: "{{ (galaxy_config_merged.gravity | default({})).process_manager | default('supervisor') }}"
__galaxy_gravity_instance_name: "{{ (galaxy_config_merged.gravity | default({})).instance_name | default(none) }}"
galaxy_gravity_wrapper_path: "/usr/local/bin/galaxyctl{{ __galaxy_gravity_instance_name | ternary('-' ~ __galaxy_gravity_instance_name, '') }}"

# Currently `mule` (aka uWSGI) and `gravity` (runs Galaxy 22.01+ under gunicorn) are supported
galaxy_systemd_mode: "{{ 'mule' if __galaxy_major_version is version('22.05', '<') else 'gravity' }}"

Expand Down
18 changes: 7 additions & 11 deletions handlers/gravity_23.0.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
---
# handlers for gravity as used in galaxy version 23.0

- name: galaxy gravity restart
command: "{{ galaxy_venv_dir }}/bin/galaxyctl -c {{ galaxy_config_file }} graceful"
environment:
GRAVITY_STATE_DIR: "{{ galaxy_gravity_state_dir }}"
listen: "restart galaxy"
become: yes
become_user: "{{ __galaxy_user_name }}"

- name: galaxyctl update
command: "{{ galaxy_venv_dir }}/bin/galaxyctl -c {{ galaxy_config_file }} update"
environment:
GRAVITY_STATE_DIR: "{{ galaxy_gravity_state_dir }}"
listen: "galaxyctl update"
become: yes
become_user: "{{ __galaxy_user_name }}"
become_user: "{{ (__galaxy_gravity_pm == 'systemd' and galaxy_systemd_root) | ternary('root', __galaxy_user_name) }}"

- name: galaxy gravity restart
command: "{{ galaxy_venv_dir }}/bin/galaxyctl -c {{ galaxy_config_file }} graceful"
listen: "restart galaxy"
become: yes
become_user: "{{ (__galaxy_gravity_pm == 'systemd' and galaxy_systemd_root) | ternary('root', __galaxy_user_name) }}"
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
- name: Include Gravity handlers (for 23.0)
import_tasks:
file: gravity_23.0.yml
when: "galaxy_systemd_mode == 'gravity' and galaxy_manage_systemd and __galaxy_major_version is version('23.0', '>=')"
when: "galaxy_systemd_mode == 'gravity' and __galaxy_major_version is version('23.0', '>=')"
31 changes: 16 additions & 15 deletions tasks/gravity.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
---
# Configure Gravity

- name: Gravity setup
- name: Gravity setup (Gravity < 1)
when: __galaxy_major_version is version('23.0', '<')
block:

- name: Register Galaxy config with Gravity
- name: Register Galaxy config with Gravity (Gravity < 1)
command: "{{ galaxy_venv_dir }}/bin/galaxyctl register {{ galaxy_config_file }}"
args:
creates: "{{ galaxy_gravity_state_dir }}/configstate.yaml"
when: __galaxy_major_version is version('23.0', '<')

- name: Update Gravity process management files
command: "{{ galaxy_venv_dir }}/bin/galaxyctl update"
args:
creates: "{{ galaxy_gravity_state_dir }}/supervisor/supervisord.conf.d"
when: __galaxy_major_version is version('23.0', '<')

- name: Update Gravity process management files
command: "{{ galaxy_venv_dir }}/bin/galaxyctl -c {{ galaxy_config_file }} update"
args:
creates: "{{ galaxy_gravity_state_dir }}/supervisor/supervisord.conf.d"
when: __galaxy_major_version is version('23.0', '>=')

environment:
GRAVITY_STATE_DIR: "{{ galaxy_gravity_state_dir }}"
remote_user: "{{ galaxy_remote_users.galaxy | default(__galaxy_remote_user) }}"
become: "{{ true if galaxy_become_users.galaxy is defined else __galaxy_become }}"
become_user: "{{ galaxy_become_users.galaxy | default(__galaxy_become_user) }}"

- name: Deploy galaxyctl wrapper script
copy:
content: |
#!/usr/bin/env sh
export GRAVITY_CONFIG_FILE={{ galaxy_config_file | quote }}
exec {{ (galaxy_venv_dir ~ '/bin/galaxyctl') | quote }} "$@"
dest: "{{ galaxy_gravity_wrapper_path }}"
mode: "0755"
when: galaxy_gravity_wrapper_path is not none
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) }}"

0 comments on commit 898d006

Please sign in to comment.