[doc] cli/run.py

This commit is contained in:
Maxime Alves LIRMM 2020-10-05 11:29:17 +02:00
parent 82e2ccbdbc
commit 584e0b6584
1 changed files with 12 additions and 4 deletions

View File

@ -1,16 +1,23 @@
#!/usr/bin/env python3
"""
cli/domain.py Defines the "halfapi run" cli command
"""
import sys
import click
import uvicorn
from .cli import cli
from halfapi.cli.domain import list_routes
from halfapi.conf import (HOST, PORT,
from .domain import list_routes
from ..conf import (HOST, PORT,
PRODUCTION, BASE_DIR, DOMAINS)
@click.option('--host', default=None)
@click.option('--port', default=None)
@cli.command()
def run(host, port):
"""
The "halfapi run" command
"""
if not host:
host = HOST
@ -20,14 +27,15 @@ def run(host, port):
port = int(port)
debug = reload = not PRODUCTION
reload = not PRODUCTION
log_level = 'info' if PRODUCTION else 'debug'
click.echo('Launching application')
sys.path.insert(0, BASE_DIR)
[ list_routes(domain) for domain in DOMAINS ]
for domain in DOMAINS:
list_routes(domain)
uvicorn.run('halfapi.app:application',
host=host,