# HG changeset patch # User Thierry Florac # Date 1515929819 -3600 # Node ID 7063ab78b465d0c6b9be5b55288eb4c18d0eb6d1 # Parent 9f851a6477b5c3cf9301917d8a6d6c7e2232e833 Add Pyramid settings to start indexer process diff -r 9f851a6477b5 -r 7063ab78b465 src/pyams_content_es/include.py --- a/src/pyams_content_es/include.py Sun Jan 14 12:35:17 2018 +0100 +++ b/src/pyams_content_es/include.py Sun Jan 14 12:36:59 2018 +0100 @@ -21,13 +21,14 @@ import sys # import interfaces -from pyams_content_es.interfaces import INDEXER_HANDLER_KEY +from pyams_content_es.interfaces import INDEXER_HANDLER_KEY, INDEXER_STARTER_KEY from pyramid.interfaces import IApplicationCreated # import packages from pyams_content_es.process import ContentIndexerProcess, ContentIndexerMessageHandler from pyams_zmq.process import process_exit_func from pyramid.events import subscriber +from pyramid.settings import asbool from zope.component.globalregistry import getGlobalSiteManager @@ -56,17 +57,18 @@ registry = getGlobalSiteManager() settings = registry.settings - start_handler = settings.get(INDEXER_HANDLER_KEY, False) + start_handler = asbool(settings.get(INDEXER_STARTER_KEY, False)) if start_handler: process = None # create content indexer process try: - process = ContentIndexerProcess(start_handler, ContentIndexerMessageHandler, registry) - logger.debug('Starting content indexer process {0!r}...'.format(process)) + process = ContentIndexerProcess(settings.get(INDEXER_HANDLER_KEY, '127.0.0.1:5557'), + ContentIndexerMessageHandler, registry) + logger.info('Starting Elasticsearch content indexer {0!r}...'.format(process)) process.start() if process.is_alive(): atexit.register(process_exit_func, process=process) - logger.debug('Started content indexer process {0!r} with PID {1}...'.format(process, process.pid)) + logger.info('Started Elasticsearch content indexer with PID {0}...'.format(process.pid)) finally: if process and not process.is_alive(): process.terminate()