如何为 Rack 应用设置端口?
问题描述:
builder.rb:
builder.rb:
def app
Rack::Builder.new do
run App.new
end.to_app
end
如何在给定的端口上运行?
How to run on a given port?
答
尝试:
Rack::Handler.default.run(app, :Port => 3000)
尽管在 config.ru
文件中运行您的应用程序并将端口指定为 rackup
的命令行选项会更常见,例如:rackup-p 3000
.
Although it would be more typical to run your app in a config.ru
file and specify port as a command line option to rackup
, e.g.: rackup -p 3000
.