tags:

views:

330

answers:

2

I need to write a super fast Ruby application to process web requests on Sinatra - and want to run it on the Ebb webserver. But I cannot work out how to do this. Could someone please help me?

+1  A: 

You need to look at Rack: http://rack.rubyforge.org/ It's pretty easy really, you have a .ru file which instructs Rack how to start your application, and in your application you have a 'call' method which is called on each request, and sends the response back to Rack.

In my_app.ru

require 'my_app'
require 'ebb'

# Rack config
use Rack::Static, urls: ['/js', '/public', '/index.html']
use Rack::ShowExceptions

# Run application
run MyApp.new

In my_app.rb

class MyApp
 def call env
    request  = Rack::Request.new env
    response = Rack::Response.new
    params = request.params

    response.body = "Hello World"
    response['Content-Length'] = response.body.size.to_s
    response.finish
  end
end

Then you specify the .ru file in your sinatra config, like:

rackup: my_app.ru
cloudhead
I dont see how the sinatra bit falls into this....where is the sinatra code? In my_app.ru?
Ash
It also turns out that ebb isnt available on Windows...does the same process apply to lighttpd?
Ash
If you're looking for a high-performance server, Nginx is pretty popular for Ruby apps these days, and I've seen it beat Lighttpd in tests.
Chuck
but they're not available for Windows are they? :(
Ash
+1  A: 

sinatra has a -s option to specify a handler. try running your app with -s ebb.

Martin DeMello