mirror of
https://github.com/ijaric/voice_assistant.git
synced 2025-05-24 22:43:26 +00:00
change architecture
This commit is contained in:
parent
28507551b0
commit
8f0365e8d2
|
@ -1,17 +1,37 @@
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
import uvicorn
|
import lib.app as app
|
||||||
|
|
||||||
import lib.app.app as app_module
|
|
||||||
import lib.app.settings as app_settings
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
app_instance = app_module.Application()
|
async def run() -> None:
|
||||||
app = app_instance.create_app()
|
settings = app.Settings()
|
||||||
settings = app_settings.settings
|
application = app.Application.from_settings(settings)
|
||||||
|
|
||||||
|
try:
|
||||||
|
await application.start()
|
||||||
|
finally:
|
||||||
|
await application.dispose()
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
try:
|
||||||
|
asyncio.run(run())
|
||||||
|
exit(os.EX_OK)
|
||||||
|
except SystemExit:
|
||||||
|
exit(os.EX_OK)
|
||||||
|
except app.ApplicationError:
|
||||||
|
exit(os.EX_SOFTWARE)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
logger.info("Exited with keyboard interruption")
|
||||||
|
exit(os.EX_OK)
|
||||||
|
except BaseException:
|
||||||
|
logger.exception("Unexpected error occurred")
|
||||||
|
exit(os.EX_SOFTWARE)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
uvicorn.run(app, host=settings.api.host, port=settings.api.port)
|
main()
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
from .health import *
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"health_router",
|
||||||
|
]
|
|
@ -0,0 +1,6 @@
|
||||||
|
from .entity import *
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"Healthy",
|
||||||
|
"Token",
|
||||||
|
]
|
|
@ -0,0 +1,11 @@
|
||||||
|
from .app import Application
|
||||||
|
from .errors import *
|
||||||
|
from .settings import Settings
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"Application",
|
||||||
|
"Settings",
|
||||||
|
"ApplicationError",
|
||||||
|
"DisposeError",
|
||||||
|
"StartServerError",
|
||||||
|
]
|
|
@ -6,10 +6,10 @@ import typing
|
||||||
import fastapi
|
import fastapi
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
|
import lib.api.v1.handlers as api_v1_handlers
|
||||||
import lib.app.errors as app_errors
|
import lib.app.errors as app_errors
|
||||||
import lib.app.settings as app_settings
|
import lib.app.settings as app_settings
|
||||||
import lib.app.split_settings as app_split_settings
|
import lib.app.split_settings as app_split_settings
|
||||||
import lib.api.v1.handlers as api_v1_handlers
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user