Skip to content

Commit 01e473d

Browse files
authored
Finish daemonstatus endpoint (#23, PR #32)
1 parent f4a6d82 commit 01e473d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scrapyd_k8s/api.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ def healthz():
2525

2626
@app.get("/daemonstatus.json")
2727
def api_daemonstatus():
28-
return { "status": "ok", "spiders": 0 }
28+
jobs = list(launcher.listjobs())
29+
return {
30+
"node_name": config.scrapyd().get("node_name", launcher.get_node_name()),
31+
"status": "ok",
32+
"pending": len([j for j in jobs if j['state'] == 'pending']),
33+
"running": len([j for j in jobs if j['state'] == 'running']),
34+
"finished": len([j for j in jobs if j['state'] == 'finished'])
35+
}
2936

3037
@app.post("/schedule.json")
3138
def api_schedule():

0 commit comments

Comments
 (0)