forked from eloravpn/EloraVPNManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (47 loc) · 1.38 KB
/
main.py
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
import uvicorn
from src import app
from src import config
from src.config import (
DEBUG,
UVICORN_HOST,
UVICORN_PORT,
UVICORN_UDS,
UVICORN_SSL_CERTFILE,
UVICORN_SSL_KEYFILE,
)
if __name__ == "__main__":
# Do NOT change workers count for now
# multi-workers support isn't implemented yet for APScheduler and XRay module
log_config = uvicorn.config.LOGGING_CONFIG
log_config["formatters"]["default"][
"fmt"
] = "%(asctime)s - %(levelname)s - %(module)s.%(funcName)s:%(lineno)d - %(message)s"
log_config["loggers"]["uvicorn"]["level"] = config.LOG_LEVEL
uds_path = UVICORN_UDS if UVICORN_UDS and len(UVICORN_UDS.strip()) > 0 else None
try:
uvicorn.run(
"main:app",
host=("127.0.0.1" if DEBUG else UVICORN_HOST),
port=UVICORN_PORT,
uds=uds_path,
ssl_certfile=UVICORN_SSL_CERTFILE,
ssl_keyfile=UVICORN_SSL_KEYFILE,
forwarded_allow_ips="*",
workers=1,
reload=DEBUG,
use_colors=True,
log_config=log_config,
)
except FileNotFoundError: # to prevent error on removing unix sock
pass
# src = FastAPI()
#
#
# @src.get("/")
# async def root():
# return {"message": "Hello World"}
#
#
# @src.get("/hello/{name}")
# async def say_hello(name: str):
# return {"message": f"Hello {name}"}