[Ruby] Tracking messages & progress

Ofer Matan ofer at stanfordalumni.org
Fri Jun 6 12:52:43 PDT 2008


Just though I'd post what I finally did:

I couldn't use backgroundrb in a windows system so I did sub divided the
whole task into sub tasks that were chained and each reported back the
status back. I wrote a small module that allowed writing the chains within a
single action like:

  def action
	chunk(:start) 
	chunk(:step1) do
                       ....
	end
	chunk(:step2) do
	                 ....
	end
	render(:update) do |page|
		page.insert_html :bottom, :log, chunk_log_html
		chunk_render(page)

	end
  end

Ajax deals with calling each chunk in order and pumping out the log. You can
see the code for action_chunk and its use @

http://pastie.org/210387 

-Ofer

-------------------------------------------------
Date: Fri, 23 May 2008 20:33:56 +0000 (UTC)
From: Philip Hallstrom <philip at pjkh.com>
Subject: Re: [Ruby] Tracking messages & progress
To: Seattle Ruby Brigade! <ruby at zenspider.com>
Message-ID: <alpine.DEB.0.99.0805232032450.13974 at gutsy>
Content-Type: TEXT/PLAIN; format=flowed; charset=us-ascii

> I am using rails to provide a web interface to deploying some test
sandboxes
> on a windows machine.
>
> The application does a chain of admins tasks:  My first cut at this was
just
> piping all output to StringIO and then when the task completes displaying
> it.
>
> This is not very pleasing as the browser hangs for a while with no
feedback.
> What I'd like is to stream the messages as they come while still keeping
the
> browser locked.
>
> What would be the best approach to this:
>
>
>
> .         Spawning the task and doing a periodic_remote_call to monitor
the
> log (though not sure how to lock the browser in this case)
>
> .         Action chunking: Chunk the big process into smaller ones that
each
> updates the page with the message and then calls the next one in the chain
-
> seems like lots of work and brittle.

Why do you need to lock the browser?  Why not spawn the task off in 
backgroundrb (or something) and set it up to report it's status somewhere 
and then set the browser to refresh periodically to see what's going on. 
If the user leaves, just make it so they can come back and pick up at that 
point...  maybe send an email on completion for those that don't want to 
wait around.

-philip


------------------------------

_______________________________________________
Ruby at zenspider.com - Seattle.rb non-commercial list
http://www.zenspider.com/seattle.rb
http://www.zenspider.com/mailman/listinfo/ruby

End of Ruby Digest, Vol 64, Issue 9
***********************************




More information about the Ruby mailing list