-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
40 lines (29 loc) · 1.03 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
import asyncio
import sys
import injection # noqa
from chromatrace import LoggingConfig, LoggingSettings, tracer
from dependency import container
from frameworks.api_app import APIService
from frameworks.socket_app import SocketService
from usecases.example_service import ExampleService
from usecases.sample import AnotherSample
sys.stdout.reconfigure(encoding="utf-8")
def api_app():
return container[APIService].rest_application
def socket_app():
return container[SocketService].socket_application
@tracer
def main():
# Optional: Set global log level
container[LoggingSettings].log_level = "DEBUG"
logger = container[LoggingConfig].get_logger("Main")
logger.info("Starting main")
service = container[ExampleService]
sample = container[AnotherSample]
asyncio.run(service.do_something())
sample.do_something()
logger.info("Finished main, Run API Service")
container[SocketService].run(main_process=False)
container[APIService].run(main_process=True)
if __name__ == "__main__":
main()