-
Notifications
You must be signed in to change notification settings - Fork 0
/
wirc_main.py
68 lines (57 loc) · 2.2 KB
/
wirc_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, info@cloudedbats.org
# License: MIT License (see LICENSE or http://opensource.org/licenses/mit).
import asyncio
import logging
import uvicorn
import wirc_core
import wirc_utils
async def main():
""" """
# WIRC logger.
wirc_utils.logger.setup_rotating_log(
logger_name=wirc_core.logger_name,
logging_dir=wirc_core.logging_dir,
log_name=wirc_core.log_file_name,
debug_log_name=wirc_core.debug_log_file_name,
)
logger = logging.getLogger(wirc_core.logger_name)
logger.info("")
logger.info("")
logger.info("Welcome to CloudedBats WIRC-2025")
logger.info("Project: https://cloudedbats.github.io")
logger.info("================ ^ö^ =================")
logger.info("")
try:
# WIRC settings.
logger.debug("WIRC - main. Startup settings.")
await wirc_core.wirc_settings.startup(settings_dir=wirc_core.settings_dir)
# WIRC core startup.
logger.debug("WIRC - main. Startup core.")
wirc_core.wirc_manager.startup()
await asyncio.sleep(0)
# API and app config.
port = wirc_core.config.get("wirc_app.port", default="8082")
port = int(port)
host = wirc_core.config.get("wirc_app.host", default="0.0.0.0")
log_level = wirc_core.config.get("wirc_app.log_level", default="info")
logger.debug("WIRC - main. Uvicorn startup at port: " + str(port) + ".")
config = uvicorn.Config(
"wirc_api:app", loop="asyncio", host=host, port=port, log_level=log_level
)
# WIRC API and app startup.
server = uvicorn.Server(config)
await server.serve()
# Shutdown actions.
logger.debug("WIRC - main. Shutdown started.")
await wirc_core.wirc_settings.shutdown()
await wirc_core.wirc_manager.shutdown()
logger.debug("WIRC - main. Shutdown done.")
except Exception as e:
message = "WIRC - main. Exception: " + str(e)
logger.error(message)
if __name__ == "__main__":
""" """
asyncio.run(main())