Skip to content
firepick1 (localhost) edited this page Jan 30, 2016 · 15 revisions

HTTP REST FireKue job service

The /firekue REST service lets you queue jobs for batch and/or steppable interactive execution. FireKue adopts a subset of the REST protocols provided by kue. FireKue also has REST protocols for steppable execution that allow users to single-step firenodejs jobs or simply execute them automatically.

Jobs

A job is a JSON object with the following fields:

attribute description
id a monotonic increasing integer provided by FireKue itself on when a job is added to the queue.
type job type (e.g., 'REST')
state Jobs can be inactive:pending execution; active:executing; complete:done successfully; failed:terminated with errors
data data semantics depend on job type. For REST jobs, this will be an array of REST requests
result result semantics depend on job type. For REST jobs, this will be an array of HTTP REST responses
progress provided by FireKue, progress is a number between 0 and 1. Jobs are done (i.e., complete or failed) when progress is 1.
tStart time when job started
tEnd time when job ended
isBusy true indicates that queue has more steps to be executed
err Error object or null

Workers

The FireKue architecture supports multiple workers:

  • each worker supports one or more job types
  • workers serialize execution and run one job at a time, step-by-step
By default, FireKue supports a single worker, the RESTworker, which executes one or more REST requests that comprise a single job of type 'REST'.

Queueing Protocols

The following REST commands may fail with HTTP501 if the designated camera is not available.

⬅️ POST /firekue/job

Add a job to the queue.

➡️ GET /firekue/job/:id

Return job with given id.

⬅️ DELETE /firekue/job/id

Delete job with given id.

➡️ GET /firekue/jobs/:from..:to/
➡️ GET /firekue/jobs/:from..:to/asc
➡️ GET /firekue/jobs/:from..:to/desc
➡️ GET /firekue/jobs/:state/:from..:to/
➡️ GET /firekue/jobs/:state/:from..:to/asc
➡️ GET /firekue/jobs/:state/:from..:to/desc
➡️ GET /firekue/jobs/:type/:state/:from..:to/desc
➡️ GET /firekue/jobs/:type/:state/:from..:to/
➡️ GET /firekue/jobs/:type/:state/asc/:from..:to/
➡️ GET /firekue/jobs/:type/:state/desc/:from..:to/

Return ordered array of job ids in the interval [from..to] with given job type and job state.

Execution Protocols

➡️ GET /firekue/step

Execute a single job step:

  1. assign jobs to idle workers
  2. step each non-idle worker

Returns queue execution status upon step completion:

{
    "progress": 1,
    "isBusy": false,
    "err": null,
}

Reserved protocols

The following URLs are reserved for future use as REST protocols

  • TBD

Remote job scripting

Upload

You can upload REST jobs using a shell script. To upload the testjob.jsono do this:

scripts/addjob.sh -h localhost json/testjob.json

Execute

Once jobs are uploaded, you can execute them one step at a time:

scripts/stepjob.sh -h raspberrypi -p 8080 

Or you can run all jobs till complete

scripts/stepjob.sh -h raspberrypi -p 8080 -a

See Also