Tail -f to a view

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

On Jan 29, 2007, at 7:44 AM, Dion H. wrote:

infinite loop and the view is never rendered

www.blogsaic.com
view, visit, vote

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.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Rob B. 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) 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!!

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 [email protected] wrote:

detached,

Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!


www.blogsaic.com
view, visit, vote

Dion H. 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!!

Dion H. 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 [email protected] wrote:

detached,

Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!


www.blogsaic.com
view, visit, vote

Hey 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs