feat: 添加 API 路由(公告/爬取/微信回调/调度器)+ 健康检查测试
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from fastapi import APIRouter
|
||||
from app.scheduler.jobs import scheduler
|
||||
from app.models.schemas import JobResponse
|
||||
|
||||
router = APIRouter(prefix="/scheduler", tags=["scheduler"])
|
||||
|
||||
|
||||
@router.get("/jobs")
|
||||
async def list_jobs():
|
||||
jobs = []
|
||||
for job in scheduler.get_jobs():
|
||||
jobs.append(JobResponse(
|
||||
id=job.id,
|
||||
name=job.name,
|
||||
next_run_time=str(job.next_run_time) if job.next_run_time else None,
|
||||
))
|
||||
return {"jobs": jobs}
|
||||
|
||||
|
||||
@router.post("/pause/{job_id}")
|
||||
async def pause_job(job_id: str):
|
||||
scheduler.pause_job(job_id)
|
||||
return {"status": "paused", "job_id": job_id}
|
||||
|
||||
|
||||
@router.post("/resume/{job_id}")
|
||||
async def resume_job(job_id: str):
|
||||
scheduler.resume_job(job_id)
|
||||
return {"status": "resumed", "job_id": job_id}
|
||||
Reference in New Issue
Block a user