public
Last active

Webmachine and Shotgun

  • Download Gist
Rakefile
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
task :shotgun do
require "rack"
require "shotgun"
 
class Shotgun::Loader
# assemble_app gets called inside the request worker
# after forking, so your_app will be loaded freshly
# for each request.
def assemble_app
require "webmachine/adapters/rack"
require "your_app"
Webmachine::Adapters::Rack.new(nil, YourApp.new.dispatcher)
end
end
 
app = Rack::Builder.new do
use Shotgun::SkipFavicon
run Shotgun::Loader.allocate
end
 
%w{INT TERM QUIT}.each {|signal| trap(signal) { exit! } }
 
options = {:Host => "127.0.0.1", :Port => 3000}
Rack::Handler.get(:webrick).run(app, options)
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.