wip
This commit is contained in:
parent
6b1c60a550
commit
839cbd0dc0
17 changed files with 213 additions and 35 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from rich.console import Console
|
||||
import typer
|
||||
import uvicorn
|
||||
|
||||
|
|
@ -27,3 +28,38 @@ def run(
|
|||
),
|
||||
):
|
||||
uvicorn.run(**get_config().api_server.dict())
|
||||
|
||||
|
||||
@api_app.command()
|
||||
def status(
|
||||
verbose: bool = typer.Option(
|
||||
False,
|
||||
callback=verbose_callback,
|
||||
help="show the log messages",
|
||||
),
|
||||
):
|
||||
import httpx
|
||||
|
||||
config = get_config()
|
||||
host = config.api_server.host
|
||||
port = config.api_server.port
|
||||
url = f"http://{host}:{port}/docs"
|
||||
|
||||
try:
|
||||
r = httpx.get(url)
|
||||
if r.status_code == 200:
|
||||
Console().print(f"[green]API: ([gold1]{url}[green]) is running")
|
||||
else:
|
||||
Console().print(f"[red]API: ([gold1]{url}[red]) is not running")
|
||||
except httpx.ConnectError:
|
||||
Console().print(f"[red]API: ([gold1]{url}[red]) is not running")
|
||||
|
||||
try:
|
||||
with config.database.engine.connect():
|
||||
Console().print(
|
||||
f"[green]database: ([gold1]{config.database.engine}[green]) is running"
|
||||
)
|
||||
except Exception as e:
|
||||
Console().print(
|
||||
f"[red]database: ([gold1]{config.database.engine}[red]) is not running"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue