-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwurb_main.py
68 lines (56 loc) · 2.11 KB
/
wurb_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python3
# -*- coding:utf-8 -*-
# Project: https://cloudedbats.github.io
# Author: Arnold Andreasson, [email protected]
# License: MIT License (see LICENSE or http://opensource.org/licenses/mit).
import asyncio
import uvicorn
import logging
import wurb_core
async def main():
""" """
# WURB logger.
wurb_core.logger.setup_rotating_log(
logging_dir=wurb_core.logging_dir,
log_name=wurb_core.log_file_name,
debug_log_name=wurb_core.debug_log_file_name,
)
logger_name = wurb_core.logger.get_logger_name()
logger = logging.getLogger(logger_name)
logger.info("")
logger.info("")
logger.info("Welcome to CloudedBats WURB-2024")
logger.info("Project: https://cloudedbats.github.io")
logger.info("================ ^ö^ =================")
logger.info("")
try:
# WURB settings.
logger.debug("WURB - main. Startup settings.")
await wurb_core.wurb_settings.startup(settings_dir=wurb_core.settings_dir)
# WURB core startup.
logger.debug("WURB - main. Startup core.")
wurb_core.wurb_manager.startup()
await asyncio.sleep(0)
# API and app config.
port = wurb_core.config.get("wurb_app.port", default="8080")
port = int(port)
host = wurb_core.config.get("wurb_app.host", default="0.0.0.0")
log_level = wurb_core.config.get("wurb_app.log_level", default="info")
logger.debug("WURB - main. Uvicorn startup at port: " + str(port) + ".")
config = uvicorn.Config(
"wurb_api:app", loop="asyncio", host=host, port=port, log_level=log_level
)
# WURB API and app startup.
server = uvicorn.Server(config)
await server.serve()
# Shutdown actions.
logger.debug("WURB - main. Shutdown started.")
await wurb_core.wurb_settings.shutdown()
await wurb_core.wurb_manager.shutdown()
logger.debug("WURB - main. Shutdown done.")
except Exception as e:
message = "WURB - main. Exception: " + str(e)
logger.error(message)
if __name__ == "__main__":
""" """
asyncio.run(main())