# HG changeset patch # User Thierry Florac # Date 1541761985 -3600 # Node ID a87a4cdd15d7d758652fda0a0ad564b6a4667e1f # Parent 5d495170a82217554c8ccca8e61196ca200ddaaf Check if documents indexer port is available before starting process to avoid zombies diff -r 5d495170a822 -r a87a4cdd15d7 src/pyams_content_es/include.py --- a/src/pyams_content_es/include.py Fri Nov 09 12:10:35 2018 +0100 +++ b/src/pyams_content_es/include.py Fri Nov 09 12:13:05 2018 +0100 @@ -27,6 +27,7 @@ # import packages from pyams_content_es.process import ContentIndexerProcess, ContentIndexerMessageHandler +from pyams_utils.protocol.tcp import is_port_in_use from pyams_utils.registry import get_global_registry from pyams_zmq.process import process_exit_func from pyramid.events import subscriber @@ -61,10 +62,16 @@ settings = registry.settings start_handler = asbool(settings.get(INDEXER_STARTER_KEY, False)) if start_handler: - process = None + # check if port is available + handler_address = settings.get(INDEXER_HANDLER_KEY, '127.0.0.1:5557') + hostname, port = handler_address.split(':') + if is_port_in_use(int(port), hostname): + logger.info("Elasticsearch content indexer port already used, aborting...") + return # create content indexer process + process = None try: - process = ContentIndexerProcess(settings.get(INDEXER_HANDLER_KEY, '127.0.0.1:5557'), + process = ContentIndexerProcess(handler_address, ContentIndexerMessageHandler, settings.get(INDEXER_AUTH_KEY), settings.get(INDEXER_CLIENTS_KEY),