diff --git a/grq2/__init__.py b/grq2/__init__.py index b1bd254..cf2b67d 100644 --- a/grq2/__init__.py +++ b/grq2/__init__.py @@ -14,8 +14,8 @@ class ReverseProxied(object): """ Wrap the application in this middleware and configure the - front-end server to add these headers, to let you quietly bind - this to a URL other than / and to an HTTP scheme that is + front-end server to add these headers, to let you quietly bind + this to a URL other than / and to an HTTP scheme that is different than what is used locally. In nginx: @@ -93,8 +93,7 @@ def resource_not_found(e): grq_es = get_grq_es() # initializing connection to Mozart's Elasticsearch -MOZART_ES_URL = app.config['MOZART_ES_URL'] -mozart_es = get_mozart_es(MOZART_ES_URL) +mozart_es = get_mozart_es() # services blueprints from grq2.services.main import mod as main_module diff --git a/grq2/es_connection.py b/grq2/es_connection.py index ba06fd1..7c27359 100644 --- a/grq2/es_connection.py +++ b/grq2/es_connection.py @@ -13,10 +13,16 @@ GRQ_ES = None -def get_mozart_es(es_url, logger=None): +def get_mozart_es(logger=None): global MOZART_ES + es_cluster_mode = app.conf['ES_CLUSTER_MODE'] + if MOZART_ES is None: - MOZART_ES = ElasticsearchUtility(es_url, logger) + if es_cluster_mode: + hosts = [app.conf.JOBS_ES_URL, app.conf.GRQ_ES_URL, app.conf.METRICS_ES_URL] + else: + hosts = [app.conf.JOBS_ES_URL] + MOZART_ES = ElasticsearchUtility(hosts, logger) return MOZART_ES @@ -28,6 +34,7 @@ def get_grq_es(logger=None): es_host = app.conf['GRQ_ES_HOST'] es_url = app.conf['GRQ_ES_URL'] region = app.conf['AWS_REGION'] + es_cluster_mode = app.conf['ES_CLUSTER_MODE'] if aws_es is True: aws_auth = BotoAWSRequestsAuth(aws_host=es_host, aws_region=region, aws_service='es') @@ -44,5 +51,9 @@ def get_grq_es(logger=None): retry_on_timeout=True, ) else: - GRQ_ES = ElasticsearchUtility(es_url, logger) + if es_cluster_mode: + hosts = [app.conf.JOBS_ES_URL, app.conf.GRQ_ES_URL, app.conf.METRICS_ES_URL] + else: + hosts = [es_url] + GRQ_ES = ElasticsearchUtility(hosts, logger) return GRQ_ES diff --git a/setup.py b/setup.py index 2a351ad..8c5770e 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='grq2', - version='2.0.24', + version='2.0.25', long_description='GeoRegionQuery REST API using ElasticSearch backend', packages=find_packages(), include_package_data=True,