In ruby, when you want to run and redirect process output, you have many options.
Here are some:
Streaming with Sinatra
From 1.3.0, sinatra supports streaming. It gets really impressive on an evented server such as Thin, considering that such behavior was reserved either to dedicated frameworks such as cramp and goliath, or even nodejs.
Spawning and Streaming
A typical CI server would spawn processes and listen in on their output. Lets see how this might happen easily.
We’ll pick option (2) for redirecting.
And here is our
Its important to instruct ruby to flush content immediately with
$stdout.sync = true otherwise, we would wait a long time to get a
non-streaming content. Try it out.
Easily enough, you can open up several browsers to esperience how great
this is. If you get a ‘stuck’ request, make sure to append some garbage
to your url such as
http://localhost:4567?r=123. I think this has to
do with browser cache mechanisms.