更新config文件,添加orm

This commit is contained in:
San Liy 2023-12-19 02:49:04 +08:00
parent 43da7d5bef
commit b2db8b8574
2 changed files with 10 additions and 1 deletions

View File

@ -60,6 +60,7 @@ class SioConfig(BaseModel):
client_id: str
client_secret: str
localhost: str
db_url: str
@dataclass

View File

@ -6,6 +6,7 @@ from sanic import Sanic, Request
from sanic.log import logger, Colors
from sanic.response import text
from socketio import AsyncClient
from tortoise.contrib.sanic import register_tortoise
from command import command_convert
from gitea_model import WebHookIssueComment, WebHookIssue, GiteaEvent
@ -21,9 +22,16 @@ def get_config() -> SioConfig:
return SioConfig(**config)
SIO_CONFIG = get_config()
register_tortoise(
app, db_url=SIO_CONFIG.db_url, modules={"models": ["orm"]}, generate_schemas=True
)
@app.before_server_start
async def setup_before_start(_app):
_app.ctx.sio_config = get_config()
_app.ctx.sio_config = SIO_CONFIG
_app.ctx.sio = AsyncClient()
start_sio_listener()