[cli] allow to run halfapi on a specified domain using the "halfapi domain --run DOMAIN" command
This commit is contained in:
parent
d1a8351997
commit
c9ecc1f8d2
|
@ -12,6 +12,7 @@ import json
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import orjson
|
import orjson
|
||||||
|
import uvicorn
|
||||||
|
|
||||||
|
|
||||||
from .cli import cli
|
from .cli import cli
|
||||||
|
@ -118,14 +119,15 @@ def list_api_routes():
|
||||||
# list_routes(domain, m_dom)
|
# list_routes(domain, m_dom)
|
||||||
|
|
||||||
|
|
||||||
@click.option('--read',default=True, is_flag=True)
|
@click.option('--run',default=True, is_flag=True)
|
||||||
|
@click.option('--read',default=False, is_flag=True)
|
||||||
@click.option('--create',default=False, is_flag=True)
|
@click.option('--create',default=False, is_flag=True)
|
||||||
@click.option('--update',default=False, is_flag=True)
|
@click.option('--update',default=False, is_flag=True)
|
||||||
@click.option('--delete',default=False, is_flag=True)
|
@click.option('--delete',default=False, is_flag=True)
|
||||||
@click.argument('config_file', type=click.File(mode='rb'), required=False)
|
@click.argument('config_file', type=click.File(mode='rb'), required=False)
|
||||||
@click.argument('domain',default=None, required=False)
|
@click.argument('domain',default=None, required=False)
|
||||||
@cli.command()
|
@cli.command()
|
||||||
def domain(domain, config_file, delete, update, create, read): #, domains, read, create, update, delete):
|
def domain(domain, config_file, delete, update, create, read, run): #, domains, read, create, update, delete):
|
||||||
"""
|
"""
|
||||||
The "halfapi domain" command
|
The "halfapi domain" command
|
||||||
|
|
||||||
|
@ -162,4 +164,15 @@ def domain(domain, config_file, delete, update, create, read): #, domains, read
|
||||||
default=ORJSONResponse.default_cast)
|
default=ORJSONResponse.default_cast)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if run:
|
||||||
|
from ..conf import CONFIG
|
||||||
|
CONFIG['domain'][domain]['enabled'] = True
|
||||||
|
port = CONFIG['domain'][domain].get('port', 3000)
|
||||||
|
|
||||||
|
uvicorn.run(
|
||||||
|
'halfapi.app:application',
|
||||||
|
port=port
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Reference in New Issue