View markdown source on GitHub

Controlling Galaxy with systemd or Supervisor

Contributors

last_modification Published: Jan 28, 2019
last_modification Last Updated: Apr 16, 2023

class: special

systemd

The current Linux init system

Used to bootstrap the user space and to manage system processes after booting

Speaker Notes


class: left

systemd

Replaces:

INI config format

Speaker Notes


systemd - Layout

Speaker Notes


systemd - Galaxy service unit

[Unit]
Description=Galaxy
After=network.target
After=time-sync.target

[Service]
UMask=022
Type=simple
User=galaxy
Group=galaxy
WorkingDirectory=/srv/galaxy/server
TimeoutStartSec=10
ExecStart=/srv/galaxy/venv/bin/uwsgi --yaml /srv/galaxy/config/galaxy.yml --stats 127.0.0.1:4010
Environment=HOME=/srv/galaxy VIRTUAL_ENV=/srv/galaxy/venv PATH=/srv/galaxy/venv/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin DOCUTILSCONFIG= PYTHONPATH=/srv/galaxy/server/lib/galaxy/jobs/rules
MemoryLimit=32G
Restart=always

MemoryAccounting=yes
CPUAccounting=yes
BlockIOAccounting=yes

[Install]
WantedBy=multi-user.target

Speaker Notes


systemd - systemctl

systemctl is the command line interface to systemd

Speaker Notes


systemd - Galaxy service

$ systemctl status galaxy
● galaxy.service - Galaxy
   Loaded: loaded (/etc/systemd/system/galaxy.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-02-26 19:46:03 UTC; 1 day 20h ago
 Main PID: 7845 (uwsgi)
    Tasks: 45 (limit: 4915)
   Memory: 569.2M (limit: 32.0G)
      CPU: 5h 43min 35.436s
   CGroup: /system.slice/galaxy.service
           ├─7845 /srv/galaxy/venv/bin/python3 /srv/galaxy/venv/bin/uwsgi --yaml /srv/galaxy/config/galaxy.yml --stats 127.0.0.1:4010
           ├─8106 /srv/galaxy/venv/bin/python3 /srv/galaxy/venv/bin/uwsgi --yaml /srv/galaxy/config/galaxy.yml --stats 127.0.0.1:4010
           ├─8111 /srv/galaxy/venv/bin/python3 /srv/galaxy/venv/bin/uwsgi --yaml /srv/galaxy/config/galaxy.yml --stats 127.0.0.1:4010
           └─8112 /srv/galaxy/venv/bin/python3 /srv/galaxy/venv/bin/uwsgi --yaml /srv/galaxy/config/galaxy.yml --stats 127.0.0.1:4010

Speaker Notes


Supervisor

The former recommended method for managing multiple Galaxy processes

Speaker Notes


Supervisor

A process manager written in Python

Speaker Notes


class: smaller

Supervisor - supervisorctl

$ supervisorctl help

default commands (type help <topic>):
=====================================
add    clear  fg        open  quit    remove  restart   start   stop  update
avail  exit   maintail  pid   reload  reread  shutdown  status  tail  version

$ supervisorctl status
galaxy_main:handler0             RUNNING    pid 30554, uptime 7 days, 23:15:11
galaxy_main:handler1             RUNNING    pid 30555, uptime 7 days, 23:15:11
galaxy_main:handler2             RUNNING    pid 30556, uptime 7 days, 23:15:10
galaxy_main:impersonate          RUNNING    pid 30567, uptime 7 days, 23:15:08
galaxy_main:installer            RUNNING    pid 30574, uptime 7 days, 23:15:07
galaxy_main:reports              RUNNING    pid 30563, uptime 7 days, 23:15:09
galaxy_main_supervisord          RUNNING    pid 2108, uptime 8 days, 6:43:54
galaxy_main_uwsgi                RUNNING    pid 3568, uptime 8 days, 6:39:07
nginx                            RUNNING    pid 1917, uptime 8 days, 6:44:21
proftpd                          RUNNING    pid 1916, uptime 8 days, 6:44:21

Speaker Notes


Supervisor - program

A config for running a Galaxy server under uWSGI has been installed at /etc/supervisor/conf.d/galaxy.conf:

[program:galaxy]
command         = uwsgi --plugin python --virtualenv /srv/galaxy/server/.venv --ini-paste /srv/galaxy/server/galaxy.yml
directory       = /srv/galaxy/server
autostart       = true
autorestart     = true
startsecs       = 10
user            = galaxy
stopsignal      = INT

Speaker Notes


Supervisor + systemd

If you prefer, you can use Supervisor to manage the Galaxy processes. The OS needs to ensure the Supervisor daemon is running, and probably manages it with systemd, as is common on most systems currently.

$ systemctl status supervisor
● supervisor.service - Supervisor process control system for UNIX
   Loaded: loaded (/lib/systemd/system/supervisor.service; enabled)
   Active: active (running) since Mon 2016-10-10 14:19:34 EDT; 3 weeks 3 days ago
 Main PID: 481 (supervisord)
   CGroup: /system.slice/supervisor.service
           ├─  481 /usr/bin/python /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
           ├─ 6264 /usr/bin/uwsgi --plugin python --virtualenv /srv/galaxy/server/.venv --ini-paste /srv/galaxy/server/galaxy.yml
           ├─ 6268 /usr/bin/uwsgi --plugin python --virtualenv /srv/galaxy/server/.venv --ini-paste /srv/galaxy/server/galaxy.yml
           ├─10109 /srv/galaxy/server/.venv/bin/python ./scripts/galaxy-main -c /srv/galaxy/server/galaxy.yml --server-name=handler0
           └─10142 /srv/galaxy/server/.venv/bin/python ./scripts/galaxy-main -c /srv/galaxy/server/galaxy.yml --server-name=handler1

Speaker Notes


Thank you!

This material is the result of a collaborative work. Thanks to the Galaxy Training Network and all the contributors! page logo Tutorial Content is licensed under Creative Commons Attribution 4.0 International License.