Add multi-farm support to the main script

This commit is contained in:
Nate Coraor
2017-11-17 17:09:36 -05:00
parent e8a22447fd
commit 49158ba38b
2 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -255,7 +255,7 @@ class UWSGIApplicationStack(MessageApplicationStack):
# Does a generalized `is_worker` attribute make sense? Hard to say w/o other stack paradigms.
if self._is_mule and self._farm_name:
# used by main.py to send a shutdown message on termination
os.environ['_GALAXY_UWSGI_FARM_NAME'] = self._farm_name
os.environ['_GALAXY_UWSGI_FARM_NAMES'] = ','.join(self._farms)
super(UWSGIApplicationStack, self).start()
def has_pool(self, pool_name):
+5 -4
View File
@@ -62,7 +62,7 @@ DEFAULT_VERBOSE = True
DESCRIPTION = "Daemonized entry point for Galaxy."
SHUTDOWN_MSG = '__SHUTDOWN__'
UWSGI_FARM_VAR = '_GALAXY_UWSGI_FARM_NAME'
UWSGI_FARMS_VAR = '_GALAXY_UWSGI_FARM_NAMES'
exit = threading.Event()
@@ -103,9 +103,10 @@ def load_galaxy_app(
def handle_signal(signum, frame):
log.info('Received signal %d, exiting', signum)
if uwsgi and 'mule_id' in dir(uwsgi) and uwsgi.mule_id() > 0:
farm = os.environ.get(UWSGI_FARM_VAR, None)
if farm:
uwsgi.farm_msg(farm, SHUTDOWN_MSG)
farms = os.environ.get(UWSGI_FARMS_VAR, None)
if farms:
for farm in farms.split(','):
uwsgi.farm_msg(farm, SHUTDOWN_MSG)
else:
uwsgi.mule_msg(SHUTDOWN_MSG, uwsgi.mule_id())
exit.set()