asynchronous-porridger #49

Merged
dm1sh merged 25 commits from asynchronous-porridger into main 2023-09-13 22:46:16 +03:00
2 changed files with 6 additions and 2 deletions
Showing only changes of commit acd0a8fbf7 - Show all commits

View File

@ -17,5 +17,4 @@ Base = declarative_base()
# Создаем таблицы
async def init_models():
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.drop_all)
await conn.run_sync(Base.metadata.create_all)
await conn.run_sync(Base.metadata.create_all)

View File

@ -3,6 +3,8 @@ import uvicorn
from .api import app as app_fastapi
from .scheduler import app as app_rocketry
from .db import init_models
class Server(uvicorn.Server):
"""Customized uvicorn.Server
@ -16,6 +18,9 @@ class Server(uvicorn.Server):
async def main():
"Run scheduler and the API"
await init_models()
server = Server(config=uvicorn.Config(app_fastapi, workers=1, loop="asyncio", host="0.0.0.0"))
api = asyncio.create_task(server.serve())