无法使用rackup和jRuby启动简单的Sinatra应用程序(Web服务器无响应)
我有一个Sinatra"hello world"应用程序,正在尝试使用jRuby运行.当我运行应用程序时,它起作用,但是当我运行机架式测试时,它不起作用.谁能告诉我这是怎么回事?
I've got a Sinatra "hello world" app that I am trying to run using jRuby. It works when I run the app, but not when I run rackup. Can anyone tell me what is going on here?
以下是该应用程序,位于文件"app.rb"中:
Here's the app, in a file 'app.rb':
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
configure do
set :bind, '0.0.0.0'
end
get '/' do
'Boo!'
end
我可以使用bundle exec ruby app.rb
运行它,并且工作正常:
I can run this using bundle exec ruby app.rb
and it works fine:
jonea@centos7andy[~/andy/sinatra_sand_jruby]%: bundle exec ruby app.rb
[2015-01-12 10:36:06] INFO WEBrick 1.3.1
[2015-01-12 10:36:06] INFO ruby 1.9.3 (2014-12-09) [java]
== Sinatra/1.4.5 has taken the stage on 4567 for development with backup from WEBrick
[2015-01-12 10:36:06] INFO WEBrick::HTTPServer#start: pid=31654 port=4567
这是我的config.ru,用于调用上述程序:
Here is my config.ru to call the above program:
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require './app'
run Sinatra::Application
如果运行此命令,它似乎可以工作,但是我无法使用网络浏览器访问服务器:
If I run this, it appears to work, but I can't access the server using a web browser:
jonea@centos7andy[~/andy/sinatra_sand_jruby]%: bundle exec rackup -p4567
[2015-01-12 10:29:06] INFO WEBrick 1.3.1
[2015-01-12 10:29:06] INFO ruby 1.9.3 (2014-12-09) [java]
[2015-01-12 10:29:06] INFO WEBrick::HTTPServer#start: pid=31553 port=4567
我注意到"Sinatra已经登台……"的可疑之处.
I note the suspicious lack of "Sinatra has taken the stage..."
好的,这不足以解释正在发生的事情,但是如果在config.ru中我替换掉了,我可以使它工作
Well, this is hardly sufficient to explain what is going on, but I can make it work if in config.ru I replace
run Sinatra::Application
使用
Sinatra::Application.run!
事实上,知道这一点使我更加困惑.机架中存在某种错误?
In fact, knowing that makes me even more confused. Some sort of bug in Rack?