|
| 1 | +Basic Usage |
| 2 | +=========== |
| 3 | + |
| 4 | +A basic example of starting and running a simple Galaxy server from a source clone in the foreground is provided in the |
| 5 | +ref:`Quick Start` guide. This section covers more typical usage for production Galaxy servers. |
| 6 | + |
| 7 | +Managing a Single Galaxy |
| 8 | +------------------------ |
| 9 | + |
| 10 | +If you have not installed Gravity separate from the Galaxy virtualenv, simply activate Galaxy's virtualenv, which will |
| 11 | +put Gravity's ``galaxyctl`` and ``galaxy`` commands on your ``$PATH``: |
| 12 | + |
| 13 | +.. code:: console |
| 14 | +
|
| 15 | + $ . /srv/galaxy/venv/bin/activate |
| 16 | + $ galaxyctl --help |
| 17 | + Usage: galaxyctl [OPTIONS] COMMAND [ARGS]... |
| 18 | +
|
| 19 | + Manage Galaxy server configurations and processes. |
| 20 | +
|
| 21 | + Options: |
| 22 | + -d, --debug Enables debug mode. |
| 23 | + -c, --config-file FILE Gravity (or Galaxy) config file to operate on. Can |
| 24 | + also be set with $GRAVITY_CONFIG_FILE or |
| 25 | + $GALAXY_CONFIG_FILE |
| 26 | + --state-dir DIRECTORY Where process management configs and state will be |
| 27 | + stored. |
| 28 | + -h, --help Show this message and exit. |
| 29 | +
|
| 30 | + Commands: |
| 31 | + configs List registered config files. |
| 32 | + deregister Deregister config file(s). |
| 33 | + exec Run a single Galaxy service in the foreground, with logging... |
| 34 | + follow Follow log files of configured instances. |
| 35 | + graceful Gracefully reload configured services. |
| 36 | + instances List all known instances. |
| 37 | + pm Invoke process manager (supervisorctl, systemctl) directly. |
| 38 | + register Register config file(s). |
| 39 | + rename Update path of registered config file. |
| 40 | + restart Restart configured services. |
| 41 | + show Show details of registered config. |
| 42 | + shutdown Shut down process manager. |
| 43 | + start Start configured services. |
| 44 | + status Display server status. |
| 45 | + stop Stop configured services. |
| 46 | + update Update process manager from config changes. |
| 47 | +
|
| 48 | +If you run ``galaxy`` or ``galaxyctl`` from the root of a Galaxy source checkout and do not specify the config file |
| 49 | +option, ``config/galaxy.yml`` or ``config/galaxy.yml.sample`` will be automatically used. This is handy for working with |
| 50 | +local clones of Galaxy for testing or development. You can skip Galaxy's lengthy and repetitive ``run.sh`` configuration |
| 51 | +steps when starting and stopping Galaxy in between code updates (you should still run ``run.sh`` after performing a |
| 52 | +``git pull`` to make sure your dependencies are up to date). |
| 53 | + |
| 54 | +Gravity can either run Galaxy via the `supervisor`_ process manager (the default) or `systemd`_. For production servers, |
| 55 | +**it is recommended that you run Gravity as root in systemd mode**. See the :ref:`Managing a Production Galaxy` section |
| 56 | +for details. |
| 57 | + |
| 58 | +As shown in the Quick Start, the ``galaxy`` command will run a Galaxy server in the foreground. The ``galaxy`` command |
| 59 | +is actually a shortcut for two separate steps: 1. read the provided ``galaxy.yml`` and write out the corresponding |
| 60 | +process manager configurations, and 2. start and run Galaxy in the foreground using the process manager (`supervisor`_). |
| 61 | +You can perform these steps separately (and in this example, start Galaxy as a backgrounded daemon instead of in the |
| 62 | +foreground): |
| 63 | + |
| 64 | +.. code:: console |
| 65 | +
|
| 66 | + $ galaxyctl update |
| 67 | + Adding service gunicorn |
| 68 | + Adding service celery |
| 69 | + Adding service celery-beat |
| 70 | + $ galaxyctl start |
| 71 | + celery STARTING |
| 72 | + celery-beat STARTING |
| 73 | + gunicorn STARTING |
| 74 | + Log files are in /srv/galaxy/var/gravity/log |
| 75 | +
|
| 76 | +When running as a daemon, the ``stop`` subcommand stops your Galaxy server: |
| 77 | + |
| 78 | +.. code:: console |
| 79 | +
|
| 80 | + $ galaxyctl stop |
| 81 | + celery-beat: stopped |
| 82 | + gunicorn: stopped |
| 83 | + celery: stopped |
| 84 | + All processes stopped, supervisord will exit |
| 85 | + Shut down |
| 86 | +
|
| 87 | +Most Gravity subcommands (such as ``stop``, ``start``, ``restart``, ...) are straightforward, but a few subcommands are |
| 88 | +worth pointing out: :ref:`update`, :ref:`graceful`, and :ref:`exec`. All subcommands are documented in the |
| 89 | +:ref:`Subcommands` section and their respective ``--help`` output. |
| 90 | + |
| 91 | +Managing a Production Galaxy |
| 92 | +---------------------------- |
| 93 | + |
| 94 | +By default, Gravity runs Galaxy processes under `supervisor`_, but setting the ``process_manager`` option to ``systemd`` |
| 95 | +in Gravity's configuration will cause it to run under `systemd`_ instead. systemd is the default init system under most |
| 96 | +modern Linux distributions, and using systemd is strongly encouraged for production Galaxy deployments. |
| 97 | + |
| 98 | +Gravity manages `systemd service unit files`_ corresponding to all of the Galaxy services that it is aware of, much like |
| 99 | +how it manages supervisor program config files in supervisor mode. If you run ``galaxyctl update`` as a non-root user, |
| 100 | +the unit files will be installed in ``~/.config/systemd/user`` and run via `systemd user mode`_. This can be useful for |
| 101 | +testing and development, but in production it is recommended to run Gravity as root, so that it installs the service |
| 102 | +units in ``/etc/systemd/system`` and are managed by the privileged systemd instance. Even when Gravity is run as root, |
| 103 | +Galaxy itself still runs as a non-root user, specified by the ``galaxy_user`` option in the Gravity configuration. |
| 104 | + |
| 105 | +It is also recommended, when running as root, that you install Gravity independent of Galaxy, rather than use the copy |
| 106 | +installed in Galaxy's virtualenv: |
| 107 | + |
| 108 | +.. code:: console |
| 109 | +
|
| 110 | + # python3 -m venv /opt/gravity |
| 111 | + # /opt/gravity/bin/pip install gravity |
| 112 | +
|
| 113 | +.. caution:: |
| 114 | + |
| 115 | + Because systemd unit file names have semantic meaning (the filename is the service's name) and systemd does not have |
| 116 | + a facility for isolating unit files controlled by an application, Gravity considers all unit files in the unit dir |
| 117 | + (``/etc/systemd/system``) that are named like ``galaxy-*`` to be controlled by Gravity. **If you have existing unit |
| 118 | + files that are named as such, Gravity will overwrite or remove them.** |
| 119 | + |
| 120 | +In systemd mode, and especially when run as root, some Gravity options are required: |
| 121 | + |
| 122 | +.. code:: yaml |
| 123 | +
|
| 124 | + gravity: |
| 125 | + process_manager: systemd |
| 126 | +
|
| 127 | + # required if running as root |
| 128 | + galaxy_user: GALAXY-USERNAME |
| 129 | + # optional, defaults to primary group of the user set above |
| 130 | + galaxy_group: GALAXY-GROUPNAME |
| 131 | +
|
| 132 | + # required |
| 133 | + virtualenv: /srv/galaxy/venv |
| 134 | + # probably necessary if your galaxy.yml is not in galaxy_root/config |
| 135 | + galaxy_root: /srv/galaxy/server |
| 136 | +
|
| 137 | +See the :ref:`Configuration` section for more details on these options and others. |
| 138 | + |
| 139 | +The ``log_dir`` option is ignored when using systemd. Logs are instead captured by systemd's logging facility, |
| 140 | +``journald``. |
| 141 | + |
| 142 | +You can use ``galaxyctl`` to manage Galaxy process starts/stops/restarts/etc. and follow the logs, just as you do under |
| 143 | +supervisor, but you can also use ``systemctl`` and ``journalctl`` directly to manage process states and inspect logs |
| 144 | +(respectively). Only ``galaxyctl update`` is necessary, in order to write and/or remove the appropriate systemd service |
| 145 | +units based on your configuration. For example: |
| 146 | + |
| 147 | +.. code:: console |
| 148 | +
|
| 149 | + # export GRAVITY_CONFIG_FILE=/srv/galaxy/config/galaxy.yml |
| 150 | + # . /srv/galaxy/venv/bin/activate |
| 151 | + (venv) # galaxyctl update |
| 152 | + Adding service galaxy-gunicorn.service |
| 153 | + Adding service galaxy-celery.service |
| 154 | + Adding service galaxy-celery-beat.service |
| 155 | +
|
| 156 | +After this point, operations can be performed with either ``galaxyctl`` or ``systemctl``. Some examples of equivalent |
| 157 | +commands: |
| 158 | + |
| 159 | +=================================== ================================================================== |
| 160 | + Gravity systemd |
| 161 | +=================================== ================================================================== |
| 162 | +``galaxy`` ``systemctl start galaxy.target && journalctl -f -u 'galaxy-*'`` |
| 163 | +``galaxyctl start`` ``systemctl start galaxy.target`` |
| 164 | +``galaxyctl start SERVICE ...`` ``systemctl start galaxy-SERVICE.service galaxy-...`` |
| 165 | +``galaxyctl restart`` ``systemctl restart galaxy.target`` |
| 166 | +``galaxyctl restart SERVICE ...`` ``systemctl restart galaxy-SERVICE.service galaxy-...`` |
| 167 | +``galaxyctl graceful`` ``systemctl reload-or-restart galaxy.target`` |
| 168 | +``galaxyctl graceful SERVICE ...`` ``systemctl reload-or-restart galaxy-SERVICE.service galaxy-...`` |
| 169 | +``galaxyctl stop`` ``systemctl start galaxy.target`` |
| 170 | +``galayxctl follow`` ``journalctl -f -u 'galaxy-*'`` |
| 171 | +=================================== ================================================================== |
| 172 | + |
| 173 | +.. _supervisor: http://supervisord.org/ |
| 174 | +.. _systemd: https://www.freedesktop.org/wiki/Software/systemd/ |
| 175 | +.. _systemd service unit files: https://www.freedesktop.org/software/systemd/man/systemd.unit.html |
| 176 | +.. _ systemd user mode: https://www.freedesktop.org/software/systemd/man/[email protected] |
0 commit comments