开发者

Display logfiles in realtime using ruby

开发者 https://www.devze.com 2022-12-21 05:37 出处:网络
I need to display logfiles in real time to user webpage using ruby/rails. Users should be able to see logfile steaming without refreshi开发者_如何转开发ng the page.

I need to display logfiles in real time to user webpage using ruby/rails. Users should be able to see logfile steaming without refreshi开发者_如何转开发ng the page.

Logfiles may not always be in the same machine which runs rails.

Is it possible in ruby/rails ?.


You could do this with automatically refreshing page, using AJAX when JavaScript is available (this avoids page flicker and extra bandwidth usage caused by a page reload).

The other approach (actually incrementally updating page) consists of two separate issues: (1) reading the file as it grows, and (2) sending the answer without closing the connection. I have seen some solutions doing this (not in Rails, though), but unfortunately they tend not to be very reliable (browsers and other parts of the system will timeout) and the users get confused when the page loading never finishes.


Ruby and Rails can read files, but the issue is going to be accessing from different machines. Are the logfiles on the same network?


What you're asking for is not necessarily Rails-specific. It's more a question of technology, IMO.

Because the classic web model is client/server and pushing data asynchronously is not standard, you'll need to figure out how to do it either by:

1) faking it by polling on the client.

2) use a different technology. For Rails, you may want to look into something like comet or websockets.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号