diff --git a/app/config.py b/app/config.py index b4ecedc..95eb82a 100644 --- a/app/config.py +++ b/app/config.py @@ -35,7 +35,7 @@ class Settings(BaseSettings): LOG_PATH: Path = Path("climate_token/log/debug.log") DB_PATH: Path = Path("climate_explorer/db/climate_activity_CHALLENGE.sqlite") - SERVER_HOST: str = "0.0.0.0" + CLIMATE_EXPLORER_SERVER_HOST: str = "0.0.0.0" BLOCK_START: int = 1_500_000 BLOCK_RANGE: int = 10_000 MIN_DEPTH: int = 4 diff --git a/app/main.py b/app/main.py index 8d717d5..f470f9b 100644 --- a/app/main.py +++ b/app/main.py @@ -38,20 +38,33 @@ async def exception_handler(request: Request, e: Exception): logger.info(f"Using settings {settings.dict()}") wait_until_dir_exists(settings.CHIA_ROOT) + server_host = '' + + if (settings.MODE == ExecutionMode.EXPLORER): + server_host = settings.CLIMATE_EXPLORER_SERVER_HOST + elif (settings.MODE == ExecutionMode.DEV): + server_host = "127.0.0.1" + elif (settings.MODE == ExecutionMode.REGISTRY): + server_host = "127.0.0.1" + elif (settings.MODE == ExecutionMode.CLIENT): + server_host = "127.0.0.1" + else : + print(f"Invalid mode {settings.MODE}!") + sys.exit(1) + if ( settings.MODE in [ExecutionMode.EXPLORER, ExecutionMode.DEV] - or settings.SERVER_HOST in ["127.0.0.1", "localhost"] + or server_host in ["127.0.0.1", "localhost"] ): uvicorn.run( app, - host=settings.SERVER_HOST, + host=server_host, port=settings.SERVER_PORT, log_level="info", log_config=log_config, ) else: print( - f'Climate Token Driver can only run on localhost in {settings.MODE.name} mode. Please update' - f' SERVER_HOST in {settings.CHIA_ROOT / settings.CONFIG_PATH}' + f'Climate Token Driver can only run on localhost in {settings.MODE.name} mode.' ) sys.exit(1) diff --git a/config.yaml b/config.yaml index 6e77c57..c96e434 100644 --- a/config.yaml +++ b/config.yaml @@ -1,6 +1,6 @@ LOG_PATH: climate_token/log/debug.log DB_PATH: climate_explorer/db/climate_activity_CHALLENGE.sqlite -SERVER_HOST: 0.0.0.0 +CLIMATE_EXPLORER_SERVER_HOST: 0.0.0.0 BLOCK_START: 1500000 BLOCK_RANGE: 10000 MIN_DEPTH: 4 diff --git a/pyproject.toml b/pyproject.toml index 74092d3..317bc0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "Chia Climate Token Driver" -version = "1.0.26" +version = "1.0.27" description = "https://github.com/Chia-Network/climate-token-driver" authors = ["Harry Hsu ", "Chia Network Inc "]