mirror of https://github.com/scrapy/scrapy.git
Merge pull request #171 from artem-dev/scrapyd_job_times
added start and stop times for scrapyd list jobs web service
This commit is contained in:
commit
26f1d5cb48
|
|
@ -21,7 +21,7 @@ A common (and useful) convention to use for the version name is the revision
|
|||
number of the version control tool you're using to track your Scrapy project
|
||||
code. For example: ``r23``. The versions are not compared alphabetically but
|
||||
using a smarter algorithm (the same `distutils`_ uses) so ``r10`` compares
|
||||
greater to ``r9``, for example.
|
||||
greater to ``r9``, for example.
|
||||
|
||||
How Scrapyd works
|
||||
=================
|
||||
|
|
@ -498,7 +498,7 @@ cancel.json
|
|||
|
||||
.. versionadded:: 0.15
|
||||
|
||||
Schedule a spider run (aka. job). If the job is pending, it will be removed. If
|
||||
Cancel a spider run (aka. job). If the job is pending, it will be removed. If
|
||||
the job is running, it will be terminated.
|
||||
|
||||
* Supported Request Methods: ``POST``
|
||||
|
|
@ -515,11 +515,6 @@ Example response::
|
|||
|
||||
{"status": "ok", "prevstate": "running"}
|
||||
|
||||
Example request passing a spider argument (``arg1``) and a setting
|
||||
(:setting:`DOWNLOAD_DELAY`)::
|
||||
|
||||
$ curl http://localhost:6800/schedule.json -d project=myproject -d spider=somespider -d setting=DOWNLOAD_DELAY=2 -d arg1=val1
|
||||
|
||||
listprojects.json
|
||||
-----------------
|
||||
|
||||
|
|
@ -594,9 +589,14 @@ Example request::
|
|||
Example response::
|
||||
|
||||
{"status": "ok",
|
||||
"pending": ["26d1b1a6d6f111e0be5c001e648c57f8", "a0571c5b9493187adb5bd07ad0faf279a86251df"],
|
||||
"running": ["422e608f9f28cef127b3d5ef93fe93992108bc5c"],
|
||||
"finished": ["5c7fd9513b1796bcd9311dd0f59bcf8973c58859"]}
|
||||
"pending": [{"id": "78391cc0fcaf11e1b0090800272a6d06", "spider": "spider1"}],
|
||||
"running": [{"id": "422e608f9f28cef127b3d5ef93fe9399", "spider": "spider2"}],
|
||||
"finished": [{"id": "2f16646cfcaf11e1b0090800272a6d06", "spider": "spider3", "start_time": "2012-09-12 10:14:03.594664", "end_time": "2012-09-12 10:24:03.594664"}]}
|
||||
|
||||
Please note:
|
||||
|
||||
* fields "start_time" and "end_time" for finished jobs were added after version 0.15.1
|
||||
* jobs data is stored in the memory so after the scrapyd service is restarted all information about pending, running and finished jobs is lost.
|
||||
|
||||
delversion.json
|
||||
---------------
|
||||
|
|
|
|||
|
|
@ -96,7 +96,9 @@ class ListJobs(WsResource):
|
|||
running = [{"id": s.job, "spider": s.spider} for s in spiders if s.project == project]
|
||||
queue = self.root.poller.queues[project]
|
||||
pending = [{"id": x["_job"], "spider": x["name"]} for x in queue.list()]
|
||||
finished = [{"id": s.job, "spider": s.spider} for s in self.root.launcher.finished
|
||||
finished = [{"id": s.job, "spider": s.spider,
|
||||
"start_time": s.start_time.isoformat(' '),
|
||||
"end_time": s.end_time.isoformat(' ')} for s in self.root.launcher.finished
|
||||
if s.project == project]
|
||||
return {"status":"ok", "pending": pending, "running": running, "finished": finished}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue