Closed manics closed 4 years ago
Barring the introduction of the new class name suffix (Mixin
) which I may have caused, this generally looks good to me. I haven't had a change to test yet. What would be your first targets for this?
I went for a mixin because it only provides a utility method for internal plugin use, it didn't seem right to construct a full Control object. Need to decide between consistency vs gradual improvement.
Once this is released I'd start by adding this to our OMERO playbooks through these role vars:
omero_server_systemd_environment
e.g. OMERO_SYSTEMD_MANAGED=1
omero_server_config_set
e.g. config set omero.server.servicemanager.checkenv OMERO_SYSTEMD_MANAGED
And similarly for OMERO.web
If there are no unforeseen issues we can consider making this mandatory in a future release of the roles.
Does $ sudo systemctl start omero-server
set or unset the environment variable? or neither?
Does bin/omero admin stop
fail because you started via systemctl
or because CHECK_FOR_THIS_VARIABLE
is not set in that environment?
[vagrant@omero ~]$ sudo -u omero-server /opt/omero/server/OMERO.server/bin/omero admin stop
ERROR: OMERO is configured to run under a service manager but CHECK_FOR_THIS_VARIABLE is not set
If you did set $ export CHECK_FOR_THIS_VARIABLE=foo
would $ omero admin stop
then work?
That's kinda how the ERROR reads.
The latter. There's no easy way to tell whether omero was started by systemd (or any other service manager), so the idea of this workaround is to set a variable in the systemd config that wouldn't otherwise be set in a normal environment. You're correct that if you manually set that variable you'd bypass the check in omero admin
.
How about:
ERROR: OMERO is configured to run under a service manager which should also set CHECK_FOR_THIS_VARIABLE
Good, thanks.
If everyones happy with this it'd be nice to include it in https://github.com/ome/omero-py/pull/248 but it's not essential.
If everyones happy with this
WFM. :+1:
Adds a config property that can be set to the name of an environment variable that is only set when running under systemd or some other service manager.
omero admin start|stop
will check this variable and abort if it's not set.Example using systemd
If you have systemd v232+ the
INVOCATION_ID
environment variable should be set by systemd so you can check for this https://serverfault.com/a/927481If you have an older version of systemd you can define your own non-empty variable in your systemd service file:
If you then attempt to start/stop omero outside systemd:
Note since the omero configuration is updated from
/opt/omero/server/config/*.omero
you must've started omero at least once with systemd after updating the configuration.I'll document this property in https://github.com/ome/openmicroscopy/blob/develop/etc/omero.properties if everyone is happy with this.
Includes a test, though I had to put it in a new file because
test_admin.py
contains a global autouser fixture that requiresOMERODIR
, which means it's not tested on Travis.A similar property can be added to
omero web
. Since these are decoupled I don't think they should share the same property, instead it would beomero.web.servicemanager.checkenv
.@stick
Note this was updated so the property is now
omero.server.servicemanager.checkenv
, notomero.admin.servicemanager.checkenv