乘客:内部服务器错误 [英] Passenger: internal server error
问题描述
我安装了 Apache、Passenger 和 Sinatra 并部署了一个应用程序.尝试访问时出错:
I installed Apache, Passenger and Sinatra and deployed an app. It gives error when trying to access:
An error occurred while starting up the preloader: it did not write a startup response in time.
Application root
/var/www/html/test
Environment (value of RAILS_ENV, RACK_ENV, WSGI_ENV and PASSENGER_ENV)
production
Ruby interpreter command
/usr/local/bin/ruby
User and groups
Unknown
Environment variables
Unknown
Ulimits
Unknown
我该如何解决?
编辑
在应用日志中,发现了这行错误:
In the application log, I found this line of error:
!> Ready
!> socket: unix:/tmp/passenger.1.0.14019/generation-0/backends/preloader.14049
!>
宝石列表:
bigdecimal (1.2.0)
builder (3.2.0)
bundler (1.3.1)
daemon_controller (1.1.1)
fastthread (1.0.7)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
passenger (4.0.0.rc4)
psych (2.0.0)
rack (1.5.2)
rack-protection (1.4.0)
rake (0.9.6)
rdoc (4.0.0)
sequel (3.45.0)
sinatra (1.3.5)
test-unit (2.0.0.0)
tilt (1.3.4)
系统版本:
Ruby 2.0
Apache 2.2
Amazon EC2 Instance
该应用在 Ruby 1.9 和Passenger 3.0 上运行良好.我刚刚升级到 2.0,Passenger 3.0 甚至无法正确编译.他们建议我使用Passenger Pre 4.0,它编译得很好,但不能运行应用程序...
The app was running fine with Ruby 1.9 and Passenger 3.0. I just upgraded to 2.0, and Passenger 3.0 does not even compile correctly. They suggested me to use Passenger Pre 4.0, and it compiled fine, but does not run the app...
推荐答案
我找到了在我的情况下导致它的原因的答案.在我的 config.ru
中,我像这样重定向 STDOUT
:
I found the answer what is causing it in my case. In my config.ru
I was redirecting STDOUT
like this:
log = File.new("logs/std.log", "a+")
STDOUT.reopen(log)
将重定向删除到日志中并重新启动.
Removing the redirect into the log and it starts up again.
看起来乘客需要 STDOUT
来检测工作的预加载器".
Looks like passenger needs STDOUT
to detect a working "preloader".
我目前正在使用以下解决方案将日志重定向到文件中并让乘客满意(基本上只是将标准输出复制到日志文件中而不是重定向):
I'm currently using the following solution to redirect the log into a file and keep passenger happy (basically just duplicating stdout into the log file and not redirecting):
log = File.new("logs/std.log", "a+")
def STDOUT.write string
log.write string
super
end
STDOUT.sync = true
这篇关于乘客:内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!