Skip to content

Setting progress of running task

treeder edited this page Mar 26, 2012 · 1 revision

When you send work to the cloud, your server's work is done, which also means your app will no longer be aware of what's happening.... or will they?

With IronWorker, it's easy to monitor status and progress. In your worker, you simply set the progress, and in your app, you simply check the status. Brilliant!

Setting Progress

To set the progress, use the set_progress method.

worker.set_progress(:percent => 25, :message => "We're a quarter of the way...")

You can put anything in the message hash and it'll be returned with the next call.

Getting Progress

The progress will show up as part of the results from the 'status' method. If you have access to the worker object, just call:

worker.status

If you have the task ID, call:

IronWorker.service.status(task_id)

Either way, you'll get a hash back that looks something like this:

{
 "task_id" => "ece460ce-12d8-11e0-8e15-12313b0440c6",
 "status" => "running",
 "msg" => nil,
 "start_time" => "2010-12-28T23:19:36+00:00",
 "end_time" => nil,
 "duration" => nil,
 "progress" => {"percent" => 25, "message" => "We're a quarter of the way..." }
}
Clone this wiki locally