-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (33 loc) · 1.18 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
from api import api
import uvicorn
import logging
import sys
from base_util import LOG_FORMAT
# initialises the root logger
logging.basicConfig(
level=logging.INFO,
stream=sys.stdout, # configure a stream handler only for now (single handler)
format=LOG_FORMAT,
)
logger = logging.getLogger()
# Start the worker
if __name__ == "__main__":
from argparse import ArgumentParser
from base_util import LOG_FORMAT
# first read the CLI arguments
parser = ArgumentParser(description="audio-extraction-worker")
parser.add_argument("--log", action="store", dest="loglevel", default="INFO")
parser.add_argument("--port", action="store", dest="port", default="5333")
args = parser.parse_args()
# initialises the root logger
logging.basicConfig(
stream=sys.stdout, # configure a stream handler only for now (single handler)
format=LOG_FORMAT,
)
# setting the loglevel
log_level = args.loglevel.upper()
logger.setLevel(log_level)
logger.info(f"Logger initialized (log level: {log_level})")
logger.info(f"Got the following CMD line arguments: {args}")
port = int(args.port)
uvicorn.run(api, port=port, host="0.0.0.0")