Streaming Files to the Browser with Ruby

I’m trying to find an efficient way to watch the server log on a web page. I don’t mind building a gem; I just want to work out the best way to do it.

Is there a way to keep a stream open to a file with Ruby (not any frameworks) and to the browser? Or will it have to be done by polling the file every x seconds?

That was the question, what i asked Streaming Files to the Browser with Ruby over stackoverflow. I done this job using cramp framework that is written by Pratik Naik.


Cramp is a fully asynchronous real-time web application framework in Ruby. It is built on top of EventMachine and primarily designed for working with larger number of open connections and providing full-duplex bi-directional communication.


1.Ruby 1.9.2+ is the preferred version of Ruby for running Cramp. Installation process is quite straight forward:

$ gem install cramp

2. Create new cramp applicaton

$cramp new my_logger

3. Edit home action and write log solution here

class HomeAction < Cramp::Action
  def start"/home/ubuntu/demo/log/development.log", "r").each_line do |line|
      render line

4. And then start the server:

$ bundle exec thin --timeout 0 -R start

You should be greeted with “logs” on browsing to

Thats it,  Thanks Pratik Naik for such a great work.