Skip to content

Commit

Permalink
fix: break out server host
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Sep 29, 2023
1 parent f07f147 commit 7b90a0e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 7b90a0e

Please sign in to comment.