mirror of
https://github.com/PaiGramTeam/FixMiYouShe.git
synced 2024-11-21 23:18:03 +00:00
fix: scheduler
This commit is contained in:
parent
ad981468a4
commit
2dfbb66dd1
@ -1,5 +1,5 @@
|
||||
httpx==0.24.1
|
||||
fastapi~=0.101.1
|
||||
fastapi~=0.110.0
|
||||
starlette
|
||||
uvicorn~=0.23.2
|
||||
pydantic
|
||||
@ -8,6 +8,6 @@ coloredlogs
|
||||
pytz
|
||||
apscheduler
|
||||
aiofiles==23.2.1
|
||||
jinja2==3.1.2
|
||||
jinja2==3.1.3
|
||||
beautifulsoup4
|
||||
lxml
|
||||
|
@ -4,6 +4,7 @@ from starlette.middleware.trustedhost import TrustedHostMiddleware
|
||||
from .env import DOMAIN, DEBUG
|
||||
from .route import get_routes
|
||||
from .route.base import UserAgentMiddleware
|
||||
from .services.scheduler import register_scheduler
|
||||
|
||||
app = FastAPI(docs_url=None, redoc_url=None, openapi_url=None)
|
||||
app.add_middleware(
|
||||
@ -15,3 +16,4 @@ app.add_middleware(
|
||||
if not DEBUG:
|
||||
app.add_middleware(UserAgentMiddleware)
|
||||
get_routes()
|
||||
register_scheduler(app)
|
||||
|
@ -1,5 +1,10 @@
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
from fastapi import FastAPI
|
||||
|
||||
scheduler = AsyncIOScheduler(timezone="Asia/ShangHai")
|
||||
if not scheduler.running:
|
||||
scheduler.start()
|
||||
|
||||
|
||||
def register_scheduler(app: "FastAPI"):
|
||||
@app.on_event("startup")
|
||||
async def start_event():
|
||||
scheduler.start()
|
||||
|
Loading…
Reference in New Issue
Block a user