fix db init
This commit is contained in:
parent
f562dc8ed7
commit
4da4cd1526
|
|
@ -14,10 +14,8 @@ except BaseException:
|
||||||
|
|
||||||
from app.core._utils.create_maria_tables import create_db_tables
|
from app.core._utils.create_maria_tables import create_db_tables
|
||||||
from app.core.storage import engine
|
from app.core.storage import engine
|
||||||
if startup_target == '__main__':
|
if startup_target != '__main__':
|
||||||
# Ensure DB schema exists (async engine)
|
# Background services get a short delay before startup
|
||||||
asyncio.get_event_loop().run_until_complete(create_db_tables(engine))
|
|
||||||
else:
|
|
||||||
time.sleep(7)
|
time.sleep(7)
|
||||||
|
|
||||||
from app.api import app
|
from app.api import app
|
||||||
|
|
@ -92,6 +90,9 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
app.ctx.memory._app = app
|
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(execute_queue(app))
|
||||||
app.add_task(queue_daemon(app))
|
app.add_task(queue_daemon(app))
|
||||||
app.add_task(uploader_bot_dp.start_polling(app.ctx.memory._telegram_bot))
|
app.add_task(uploader_bot_dp.start_polling(app.ctx.memory._telegram_bot))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue