Skip to content

Commit

Permalink
Allow for bonsai elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
drkane committed Jul 12, 2017
1 parent 15b1498 commit 6fcc99a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: python server/server.py -p $PORT -h "0.0.0.0" --server "gunicorn" --es-host $ES_HOST --es-port $ES_PORT --es-url-prefix $ES_URL_PREFIX
web: python server/server.py -p $PORT -h "0.0.0.0" --server "gunicorn"
23 changes: 17 additions & 6 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,23 @@ def main():

args = parser.parse_args()

app.config["es"] = Elasticsearch(
host=args.es_host,
port=args.es_port,
url_prefix=args.es_url_prefix,
use_ssl=args.es_use_ssl
)
if os.environ.get("BONSAI_URL"):
bonsai = os.environ['BONSAI_URL']
auth = re.search('https\:\/\/(.*)\@', bonsai).group(1).split(':')
host = bonsai.replace('https://%s:%s@' % (auth[0], auth[1]), '')
app.config["es"] = Elasticsearch(
host=host,
port=443,
use_ssl=True,
http_auth=(auth[0], auth[1])
)
else:
app.config["es"] = Elasticsearch(
host=args.es_host,
port=args.es_port,
url_prefix=args.es_url_prefix,
use_ssl=args.es_use_ssl
)
app.config["es_index"] = args.es_index
app.config["es_type"] = args.es_type

Expand Down

0 comments on commit 6fcc99a

Please sign in to comment.