环境哈希传递到每一个组件堆栈中有一个SERVER_SOFTWARE
键。运行此并遵守网页上的输出:如果有rackup执行
require 'rack'
class EnvPrinter
def call env
[200, {'content-type' => 'text/plain'}, [env.inspect]]
end
end
run EnvPrinter.new
,在WEBrick将用作服务器(这是默认值),SERVER_SOFTWARE
将会像WEBrick/1.3.1 (Ruby/1.9.3/2013-01-15)
。如果使用独角兽,它将类似Unicorn 4.5.0
。此机架代码根据运行的服务器返回自定义响应:
require 'rack'
class EnvPrinter
def call env
response = case env.fetch('SERVER_SOFTWARE')
when /webrick/i then 'Running on webrick'
when /unicorn/i then 'Running on unicorn'
when /thin/i then 'Running on thin'
else "I don't recognize this server"
end
[200, {'content-type' => 'text/plain'}, [response]]
end
end
run EnvPrinter.new
我想知道这可能对您有所帮助。 http://stackoverflow.com/questions/7193635/change-default-server-for-rails – Vinay 2013-02-08 11:30:06