This repository has been archived on 2022-07-14. You can view files and clone it, but cannot push or open issues or pull requests.
sh_gismo/src/gismo/main.py

44 lines
1.0 KiB
Python
Raw Normal View History

2021-11-15 00:52:49 +01:00
import asyncio
2021-11-17 19:35:42 +01:00
from typing import Optional
2021-11-15 00:52:49 +01:00
2021-11-16 18:34:41 +01:00
from cpl_core.application import ApplicationABC, ApplicationBuilder
2021-11-15 00:52:49 +01:00
2021-11-19 08:58:38 +01:00
from gismo.application import Gismo
from gismo.startup import Startup
2021-11-16 09:12:44 +01:00
from modules.boot_log.boot_log_extension import BootLogExtension
2021-11-15 00:52:49 +01:00
2021-11-19 09:21:04 +01:00
2021-11-17 19:35:42 +01:00
class Main:
2021-11-19 09:21:04 +01:00
2021-11-17 19:35:42 +01:00
def __init__(self):
2021-11-19 08:58:38 +01:00
self._gismo: Optional[Gismo] = None
2021-11-15 00:52:49 +01:00
2021-11-17 19:35:42 +01:00
async def main(self):
2021-11-19 08:58:38 +01:00
app_builder = ApplicationBuilder(Gismo)
2021-11-17 19:35:42 +01:00
app_builder.use_extension(BootLogExtension)
app_builder.use_startup(Startup)
2021-11-19 08:58:38 +01:00
self._gismo: Gismo = await app_builder.build_async()
await self._gismo.run_async()
2021-11-19 09:21:04 +01:00
2021-11-17 19:35:42 +01:00
async def stop(self):
2021-11-19 08:58:38 +01:00
await self._gismo.stop_async()
2021-11-15 00:52:49 +01:00
2021-11-19 09:21:04 +01:00
2021-11-15 00:52:49 +01:00
if __name__ == '__main__':
2021-11-17 19:35:42 +01:00
main = Main()
2021-11-15 00:52:49 +01:00
ml = asyncio.get_event_loop()
2021-11-17 19:35:42 +01:00
try:
ml.run_until_complete(main.main())
except KeyboardInterrupt:
2021-11-19 09:21:04 +01:00
ml.run_until_complete(main.stop())
# ((
# ( `)
# ; / ,
# / \/
# / |
# / ~/
# / ) ) ~ edraft
# ___// | /
# `--' \_~-,