updates to the API and docs
parent
241b638449
commit
d4b6c9d715
|
|
@ -23,6 +23,13 @@ standard hosts file convention: `IP address <tab> Name`
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
|
|
||||||
|
## First-time Setup
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ touch hosts
|
||||||
|
$ tr -dc A-Za-z0-9 </dev/urandom | head -c 16 > tokens
|
||||||
|
```
|
||||||
|
|
||||||
## Python Application
|
## Python Application
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|
@ -31,7 +38,7 @@ $ source .venv/bin/acticate
|
||||||
$ pip install -r requirements.txt
|
$ pip install -r requirements.txt
|
||||||
|
|
||||||
# run the application
|
# 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
|
## Sudoers configuration
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ async def register_service(name: str, ip: str):
|
||||||
registry[name] = [ip]
|
registry[name] = [ip]
|
||||||
|
|
||||||
update_hosts_file(registry)
|
update_hosts_file(registry)
|
||||||
|
reload_config()
|
||||||
return registry
|
return registry
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,8 +83,10 @@ async def register_service(name: str, ip: str):
|
||||||
updated = [addr for addr in current if addr != ip]
|
updated = [addr for addr in current if addr != ip]
|
||||||
registry[name] = updated
|
registry[name] = updated
|
||||||
update_hosts_file(registry)
|
update_hosts_file(registry)
|
||||||
|
reload_config()
|
||||||
return registry
|
return registry
|
||||||
|
|
||||||
|
|
||||||
@app.get("/service/{name}")
|
@app.get("/service/{name}")
|
||||||
async def read_service(name: str):
|
async def read_service(name: str):
|
||||||
"""Reads the hosts file, produces a service catalog entry."""
|
"""Reads the hosts file, produces a service catalog entry."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue