I am using file-tail to tail logs in a ruby script
this works fine when run as a ruby script
File::Tail::Logfile.open(''log/development.log'', :rewind =>
10) do |log|
log.tail { |line| puts line }
end
but in rails, when run from a def in a controller, it goes into an infinite
loop and the view is never rendered
is there a way to use file::tail to tail a file and redirect that to a view
without looping
cheers
dion
http://rubyforge.org/projects/file-tail
--
www.blogsaic.com
view, visit, vote
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Jan 29, 2007, at 7:44 AM, Dion Hewson wrote:> I am using file-tail to tail logs in a ruby script > > this works fine when run as a ruby script > > File::Tail::Logfile.open(''log/development.log'', :rewind => 10) do | > log| > log.tail { |line| puts line } > end > > but in rails, when run from a def in a controller, it goes into an > infinite loop and the view is never rendered > > is there a way to use file::tail to tail a file and redirect that > to a view without looping > > cheers > > dion > > http://rubyforge.org/projects/file-tail > > -- > www.blogsaic.com > view, visit, voteYou don''t want to tail a file from a controller, it keeps trying to get new content from the end of the file. If you want to show the last 10 lines, just use the rewind(10) and read until EOF. If you want to simulate the dynamic following of the contents of a file, you need to have a detached, long-running process to do the "tail" and have a periodically_call_remote() in your view to get the new contents. BackgrounDRb can be a good option for this kind of thing. -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn wrote:> You don''t want to tail a file from a controller, it keeps trying to get new > content from the end of the file. If you want to show the last 10 lines, > just use the rewind(10) and read until EOF. If you want to simulate the > dynamic following of the contents of a file, you need to have a detached, > long-running process to do the "tail" and have a periodically_call_remote() > in your view to get the new contents. > BackgrounDRb can be a good option for this kind of thing.Google for my street name, "how to chat", and Rails. I show how to use periodically_call_remote with some (dated) <script> tricks to send a "high water mark" back to the server. It only sends chat lines created since the last high water mark. -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
what I actually want to do is simply output the production.log to a view so that I dont have to log into my server to monitor the logs I want to just visit www.blogsaic.com/log and watch the log scroll by with the same effect as "tail -f production.log" is there a more straight forward way just using logger? On 1/30/07, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Rob Biedenharn wrote: > > > You don''t want to tail a file from a controller, it keeps trying to get > new > > content from the end of the file. If you want to show the last 10 > lines, > > just use the rewind(10) and read until EOF. If you want to simulate the > > dynamic following of the contents of a file, you need to have a > detached, > > long-running process to do the "tail" and have a > periodically_call_remote() > > in your view to get the new contents. > > BackgrounDRb can be a good option for this kind of thing. > > Google for my street name, "how to chat", and Rails. I show how to use > periodically_call_remote with some (dated) <script> tricks to send a > "high water mark" back to the server. It only sends chat lines created > since the last high water mark. > > -- > Phlip > http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! > > > >-- www.blogsaic.com view, visit, vote --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dion Hewson wrote:> I want to just visit www.blogsaic.com/log > > and watch the log scroll by with the same effect as "tail -f production.log" > > is there a more straight forward way just using logger?Asked and answered. A web page, by design, is always stateless, event-driven, and intermittently connected. To scroll a log, you need a periodical Ajax call, a scrolling div of output, and a high-water mark. Chat. -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dion Hewson wrote:> what I actually want to do is simply output the production.log to a view > so > that I dont have to log into my server to monitor the logs > > I want to just visit www.blogsaic.com/log > > and watch the log scroll by with the same effect as "tail -f > production.log" > > is there a more straight forward way just using logger? > > On 1/30/07, Phlip <phlip2005-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> detached, >> -- >> Phlip >> http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! >> >> > >> > > > -- > www.blogsaic.com > view, visit, voteHey Dion, Did you ever come up with a solution? I am working on the very same thing. I have a working (mostly) tail to a div container, but it is slow and I am not getting all the output from the tail. Wondered how you have made out. Any feedback would be great. Thanks! tonyd -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---