On Nov 2, 2010, at 2:51 AM, Sohan J. wrote:
> Hey guys, I''m just starting out with Rails, and I''m
trying to build a
> tool that acts as a server for collecting log output across many
> machines. I was wondering if anyone could point me in the right
> direction of how to continuously post text to a rails page.
>
> For example, I have a few machines that continuously run cron jobs and
> other scripts. Each machine is identifiable by its mac address. So I
> was thinking they could keep sending POST requests of the form
> server:3000/machines?macaddr=0.0.0.0&message="logoutput"
>
> Is there a more sensible way to do this? Could anyone point me to
> some
> docs on how I can implement this functionality? I have the basic
> structure with scaffolding, but I''m not exactly sure how I can
keep
> appending text to a given page. Thanks
There''s a PeriodicalUpdater control in Prototype.js that can run an
Ajax request from your page to your server and update a portion of the
page with any changes. Think about how Campfire works -- watching what
the other people are typing is about what you''re describing here.
But it doesn''t work from the direction I think you''re
intending. Your
cron jobs could indeed send their POST requests to your server, but
there, a daemon would have to listen for them, save them to a
database, and then your observer screen would query that database,
sending in its request the last-received row id, and ask "Anything new
after id 12345?" If so, the server would need to send back just the
new stuff and PeriodicalUpdater would insert that on your screen.
Have a look around for a Campfire clone write-up (should be plenty of
these, I''ve built one for learning purposes, but never released it
anywhere).
Walter
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.