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