Passenger 下机架上的 Sinatra 返回 0 字节页面
我正在尝试编写一个将在共享 Passenger 服务器上运行的 Sinatra 应用程序。现在,我很高兴能得到一个“hello world”,但有些事情不太正常。我有:
config.ru
require 'vendor/sinatra-lib/sinatra.rb'
set :environment, :production
disable :run
require 'myapp.rb'
run Sinatra::Application
myapp.rb
get '/' do
"Hello world!"
end
当然,sinatra 所需的所有支持库都位于 /vendor/sinatra-lib 下。我可以在我的本地机器上加载这个精确的负载,并且它运行得像冠军一样。但是,在远程计算机上,我尝试访问的任何 URL 都会收到 0 字节响应。请注意,我有一个 /public 目录,并且我可以成功查看其中的页面,因此我猜 Rack 仍在响应。另外,我可以毫无问题地运行基本的 Rack 应用程序,因此必须正确配置 Rack(至少对于运行 Rack 应用程序而言是正确的)。
此时我唯一能想到的就是检查远程服务器上Rack的版本等。我无法完全控制该盒子,因此我实际上没有日志输出可供共享。如果它很重要的话,我可以尝试追查它,但我希望有人会突然发现一些东西。
I'm trying to write a Sinatra app that will run on a shared Passenger server. For now, I'd be happy just getting a "hello world", but something isn't working quite right. I have:
config.ru
require 'vendor/sinatra-lib/sinatra.rb'
set :environment, :production
disable :run
require 'myapp.rb'
run Sinatra::Application
myapp.rb
get '/' do
"Hello world!"
end
and of course all the support libs I need for sinatra are under /vendor/sinatra-lib. I can rackup this exact load on my local machine, and it runs like a champ. However, on the remote machine, I get 0-byte responses for any URL I try to visit. Note that I have a /public directory, and I can view pages out of that successfully, so I guess Rack is still responding. Also, I can run a basic Rack app without any problems, so Rack must be configured correctly (at least, correctly for running Rack apps).
At this point, the only thing I can think of is to check the version of Rack, etc, on the remote server. I don't have full control over the box, so I don't really have log output to share. I can try to chase it down, if it's important, but I'm hoping something will jump out at somebody.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为问题是其他 sinatra 文件不在加载目录中。尝试将
vendor/sinatra-lib
重命名为vendor/sinatra
,如果仍然不起作用,请尝试将其添加到config 的顶部。 ru
,而不是require 'vendor/...'
一点旁注:您不需要将文件扩展名 (.rb) 传递给
require
,因此您可以使用require 'myapp'
而不是require 'myapp.rb'
。I think the problem is that the other sinatra files isn't in the load dir. Try to rename
vendor/sinatra-lib
intovendor/sinatra
, and if it still doesn't work, try to add this in the top of yourconfig.ru
, in stead ofrequire 'vendor/...'
A little side note: You are not required to pass the file extension (.rb) to
require
, so you could dorequire 'myapp'
instead ofrequire 'myapp.rb'
.感谢大家的参与,结果发现是一个依赖性问题——我部署到的服务器运行的 Rack 版本太旧,无法支持 Sinatra。不过,还有很多其他值得思考的好东西。
Thank you all for playing, turned out to be a dependency issue -- the server I was deployed to was running a version of Rack that was too old to support Sinatra. Lots of good other stuff to think about, though.