fix db init

This commit is contained in:
user 2025-08-24 13:23:05 +03:00
parent f562dc8ed7
commit 4da4cd1526
1 changed files with 5 additions and 4 deletions

View File

@ -14,10 +14,8 @@ except BaseException:
from app.core._utils.create_maria_tables import create_db_tables
from app.core.storage import engine
if startup_target == '__main__':
# Ensure DB schema exists (async engine)
asyncio.get_event_loop().run_until_complete(create_db_tables(engine))
else:
if startup_target != '__main__':
# Background services get a short delay before startup
time.sleep(7)
from app.api import app
@ -92,6 +90,9 @@ if __name__ == '__main__':
app.ctx.memory._app = app
# Ensure DB schema exists using the same event loop as Sanic
app.add_task(create_db_tables(engine))
app.add_task(execute_queue(app))
app.add_task(queue_daemon(app))
app.add_task(uploader_bot_dp.start_polling(app.ctx.memory._telegram_bot))