mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-07-06 22:42:14 +08:00
feat: 更新循环任务调度器,修复启动后服务器停不掉的问题
This commit is contained in:
8
main.py
8
main.py
@ -14,6 +14,7 @@ from common import lxsecurity
|
||||
from common import log
|
||||
from common import Httpx
|
||||
from common import variable
|
||||
from common import scheduler
|
||||
from aiohttp.web import Response
|
||||
import ujson as json
|
||||
import threading
|
||||
@ -130,6 +131,7 @@ async def run_app():
|
||||
logger.info(f"监听 -> http://{host}:{port}")
|
||||
|
||||
async def initMain():
|
||||
await scheduler.run()
|
||||
variable.aioSession = aiohttp.ClientSession()
|
||||
try:
|
||||
await run_app()
|
||||
@ -147,7 +149,11 @@ async def initMain():
|
||||
logger.error("遇到未知错误,请查看日志")
|
||||
logger.error(traceback.format_exc())
|
||||
finally:
|
||||
await variable.aioSession.close()
|
||||
logger.info('wating for sessions to complete...')
|
||||
if variable.aioSession:
|
||||
await variable.aioSession.close()
|
||||
|
||||
variable.running = False
|
||||
logger.info("Server stopped")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user