문제

I installed the mongrel gem because I need it on my workstation for rare occasions, and now it's my default Rails (2) server. I know I could specify script/server webrick on the command line, but the fact is that I'd like to have my system (or app) default to webrick, and only use mongrel when specified.

Anybody know how to arrange that?

Specs: WinXP, Rails 2.3.12, Ruby 1.8.7

도움이 되었습니까?

해결책

Ok here are a few options:

Option one - One off: Always add webrick as a command line arg

Open script/server and insert a line between the two requires

#!/usr/bin/env ruby
require File.expand_path('../../config/boot',  __FILE__)
ARGV.unshift "webrick"
require 'commands/server'

Option two - Global: Edit the commands/server.rb file that launches rails

gem which railties -> tells you where the startup code is Open the file at lib/commands/server.rb

Around line 45 edit the logic so that webrick is always launched by default.

server = Rack::Handler.get(ARGV.first) rescue nil
unless server
  begin
    server = Rack::Handler::WEBrick # was Mongrel
  rescue LoadError => e
    server = Rack::Handler::WEBrick
  end
end

Option 3 - Cleanest but most involved:

Switch to Bundler and manage your dependencies directly. This is more work but positions you for switching to rails 3 at some point which might be nice depending on the life cycle of the application. There's a tutorial for rails 2.3 here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top