Change default server for Rails

有些话、适合烂在心里 提交于 2020-01-06 08:28:22

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/7193635/change-default-server-for-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!