-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
53 lines (38 loc) · 1.15 KB
/
manage.py
File metadata and controls
53 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/python
import uvicorn
import click
from bridge.app import create_app
def create_core():
return create_app(debug=True, cli=True)
def init():
"""
Init database, application
:return:
"""
@click.group()
def cli():
pass
@click.command()
@click.option('--host', default='0.0.0.0', help='Server host address')
@click.option('--port', default=8000, help='Server port')
@click.option('--log-level', default='info', help='Log level')
def run(host: str = '0.0.0.0', port: int = 8000, log_level: str = 'info'):
uvicorn.run(create_core(), host=host, port=port, log_level=log_level)
@click.command()
@click.option('--host', default='0.0.0.0', help='Server host address')
@click.option('--port', default=8000, help='Server port')
@click.option('--log-level', default='info', help='Log level')
def debug(host: str = '0.0.0.0', port: int = 8000, log_level: str = 'info'):
uvicorn.run(
create_app(),
host=host, port=port,
log_level='debug',
debug=True,
reload=True,
loop='uvloop',
lifespan='on',
)
cli.add_command(run)
cli.add_command(debug)
if __name__ == "__main__":
cli()