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
+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()