#12 introduce GATEWAY_PORT, rename GATEWAY_HOST and GATEWAY_PROTOCOL to EXTERNAL_HOST and EXTERNAL_PROTOCOL

Keep GATEWAY_HOST and GATEWAY_PROTOCOL for backwards compatibility (for now)
This commit is contained in:
Alok Saldanha
2019-11-17 19:03:47 -05:00
parent 91c9607808
commit 9532375eb0
6 changed files with 15 additions and 19 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ class CacheEntry:
dataset = self.dataset
gateway_basepath = (
f"{env.gateway_protocol}://{env.gateway_host}/view/{dataset}/"
f"{env.external_protocol}://{env.external_host}/view/{dataset}/"
)
subpath = path[len(dataset) :] # noqa: E203
+7 -6
View File
@@ -9,11 +9,13 @@
import os
import logging
import socket
cellxgene_location = os.environ.get("CELLXGENE_LOCATION")
cellxgene_data = os.environ.get("CELLXGENE_DATA")
gateway_host = os.environ.get("GATEWAY_HOST")
gateway_protocol = os.environ.get("GATEWAY_PROTOCOL")
gateway_port = int(os.environ.get("GATEWAY_PORT", "5005"))
external_host = os.environ.get("EXTERNAL_HOST", os.environ.get("GATEWAY_HOST", f"localhost:{gateway_port}"))
external_protocol = os.environ.get("EXTERNAL_PROTOCOL", os.environ.get("GATEWAY_PROTOCOL", "http"))
ip = os.environ.get("GATEWAY_IP")
extra_scripts = os.environ.get("GATEWAY_EXTRA_SCRIPTS")
ttl = os.environ.get("GATEWAY_TTL")
@@ -22,12 +24,13 @@ enable_upload = os.environ.get("GATEWAY_ENABLE_UPLOAD", "").lower() in ['true',
env_vars = {
"CELLXGENE_LOCATION": cellxgene_location,
"CELLXGENE_DATA": cellxgene_data,
"GATEWAY_HOST": gateway_host,
"GATEWAY_PROTOCOL": gateway_protocol,
"GATEWAY_IP": ip,
}
optional_env_vars = {
"EXTERNAL_HOST": external_host,
"EXTERNAL_PROTOCOL": external_protocol,
"GATEWAY_PORT": gateway_port,
"GATEWAY_EXTRA_SCRIPTS": extra_scripts,
"GATEWAY_TTL": ttl,
"GATEWAY_ENABLE_UPLOAD": enable_upload,
@@ -47,8 +50,6 @@ def validate():
export CELLXGENE_LOCATION=~/anaconda/envs/cellxgene-dev/bin/cellxgene
export CELLXGENE_DATA=../cellxgene_data
export GATEWAY_HOST=localhost:5005
export GATEWAY_PROTOCOL=http
export GATEWAY_IP=127.0.0.1
"""
)
+1 -1
View File
@@ -14,6 +14,6 @@ from json import loads
def get_extra_scripts():
# can be array of script tags to inject on every page, e.g. for google analytics could be
# ['https://www.googletagmanager.com/gtag/js?id=UA-123456-2',
# f"{env.gateway_protocol}://{env.gateway_host}/static/js/google_ua.js"]
# f"{env.external_protocol}://{env.external_host}/static/js/google_ua.js"]
# where google_ua.js is a script you add to the static/js folder prior to deployment.
return [] if env.extra_scripts is None else loads(env.extra_scripts)
+2 -2
View File
@@ -37,7 +37,7 @@ from cellxgene_gateway.util import current_time_stamp
app = Flask(__name__)
cache = BackendCache()
location = f"{env.gateway_protocol}://{env.gateway_host}"
location = f"{env.external_protocol}://{env.external_host}"
@app.errorhandler(CellxgeneException)
@@ -232,7 +232,7 @@ def main():
background_thread.start()
app.launchtime = current_time_stamp()
app.run(host="0.0.0.0", port=5005, debug=False)
app.run(host="0.0.0.0", port=env.gateway_port, debug=False)
if __name__ == "__main__":