Skip to content

Commit

Permalink
Finish daemonstatus endpoint (#23, PR #32)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlerkin authored Sep 18, 2024
1 parent f4a6d82 commit 01e473d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scrapyd_k8s/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ def healthz():

@app.get("/daemonstatus.json")
def api_daemonstatus():
return { "status": "ok", "spiders": 0 }
jobs = list(launcher.listjobs())
return {
"node_name": config.scrapyd().get("node_name", launcher.get_node_name()),
"status": "ok",
"pending": len([j for j in jobs if j['state'] == 'pending']),
"running": len([j for j in jobs if j['state'] == 'running']),
"finished": len([j for j in jobs if j['state'] == 'finished'])
}

@app.post("/schedule.json")
def api_schedule():
Expand Down

0 comments on commit 01e473d

Please sign in to comment.