This commit is contained in:
mirai
2026-01-03 12:00:52 +03:00
parent 8b58bf4db3
commit 264d19e932
6 changed files with 5 additions and 31 deletions
-3
View File
@@ -7,7 +7,6 @@ from sanic_ext import Extend
from .managers import ConnectionManager
from .stores import MessageStore, UserSessionStore
from .srp_auth import SRPAuthManager
from .logger import logger
from .routes import register_routes
@@ -32,12 +31,10 @@ def create_app(password: str = "", name: str = "cmd-chat-server") -> Sanic:
def register_lifecycle(app: Sanic) -> None:
@app.before_server_start
async def setup(app: Sanic):
logger.info("Server starting...")
app.ctx.cleanup_task = asyncio.create_task(cleanup_stale_sessions(app))
@app.after_server_stop
async def teardown(app: Sanic):
logger.info("Server shutting down...")
if app.ctx.cleanup_task:
app.ctx.cleanup_task.cancel()
with suppress(asyncio.CancelledError):