diff --git a/README.md b/README.md index 7920b74..5f743c8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,13 @@ standard hosts file convention: `IP address Name` # Setup +## First-time Setup + +```sh +$ touch hosts +$ tr -dc A-Za-z0-9 tokens +``` + ## Python Application ```sh @@ -31,7 +38,7 @@ $ source .venv/bin/acticate $ pip install -r requirements.txt # run the application -$ flask run server.py --host 0.0.0.0 --port 8000 +$ fastapi run server.py --host 0.0.0.0 --port 8000 ``` ## Sudoers configuration diff --git a/server.py b/server.py index c59a706..96c4407 100644 --- a/server.py +++ b/server.py @@ -70,6 +70,7 @@ async def register_service(name: str, ip: str): registry[name] = [ip] update_hosts_file(registry) + reload_config() return registry @@ -82,8 +83,10 @@ async def register_service(name: str, ip: str): updated = [addr for addr in current if addr != ip] registry[name] = updated update_hosts_file(registry) + reload_config() return registry + @app.get("/service/{name}") async def read_service(name: str): """Reads the hosts file, produces a service catalog entry."""