diff options
author | Muriithi Frederick Muriuki | 2018-01-30 13:07:58 +0300 |
---|---|---|
committer | Pjotr Prins | 2018-03-26 09:24:35 +0000 |
commit | e0295504fb0097db394e99568339e24a71406123 (patch) | |
tree | 09fc1b0505c479fc6be5a28e5a02e385bedde871 /wqflask/utility | |
parent | 3029ae6ffe66f083f02d35d39e09500f76977197 (diff) | |
download | genenetwork2-e0295504fb0097db394e99568339e24a71406123.tar.gz |
Fail safely if elasticsearch is down or unconfigured
* If elasticsearch server is down, or the configuration variables are
not provided at startup or in a configuration file, then do not allow
the system to simply crash, but instead, inform the user that they
cannot use the services that depend on elasticsearch to be running.
Diffstat (limited to 'wqflask/utility')
-rw-r--r-- | wqflask/utility/elasticsearch_tools.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/wqflask/utility/elasticsearch_tools.py b/wqflask/utility/elasticsearch_tools.py index c2c999ea..8b8ad9cc 100644 --- a/wqflask/utility/elasticsearch_tools.py +++ b/wqflask/utility/elasticsearch_tools.py @@ -1,10 +1,14 @@ -from elasticsearch import Elasticsearch, TransportError -from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT +es = None +try: + from elasticsearch import Elasticsearch, TransportError + from utility.tools import ELASTICSEARCH_HOST, ELASTICSEARCH_PORT -es = Elasticsearch([{ - "host": ELASTICSEARCH_HOST - , "port": ELASTICSEARCH_PORT -}]) + es = Elasticsearch([{ + "host": ELASTICSEARCH_HOST + , "port": ELASTICSEARCH_PORT + }]) if (ELASTICSEARCH_HOST and ELASTICSEARCH_PORT) else None +except: + es = None def get_user_by_unique_column(column_name, column_value): user_details = None |