乘客:内部服务器错误
我安装了Apache,Passenger和Sinatra并部署了一个应用程序。 尝试访问时出错:
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
我该如何解决?
编辑
在应用程序日志中,我发现了以下错误:
!> Ready !> socket: unix:/tmp/passenger.1.0.14019/generation-0/backends/preloader.14049 !>
gem清单:
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,它编译得很好,但不运行应用程序……
在我的案例中,我找到了答案。 在我的config.ru
我正在重定向STDOUT
如下所示:
log = File.new("logs/std.log", "a+") STDOUT.reopen(log)
将重定向删除到日志中,然后再次启动。
看起来乘客需要STDOUT
才能检测出正常工作的“预加载器”。
编辑:我目前正在使用以下解决方案将日志重定向到一个文件并让乘客满意(基本上只是将stdout复制到日志文件而不是重定向):
log = File.new("logs/std.log", "a+") def STDOUT.write string log.write string super end STDOUT.sync = true
如果上面没有为您解决,我有完全相同的错误消息与不同的原因。
就我而言,我们使用的是外部数据库服务器而且已经关闭。
重新启动外部数据库服务器可以解决问题。
但在我们解决这个问题之前,我们花了很多时间考虑重新编译乘客等。
希望这个笔记能节省一些时间。
要解决此问题,请按照phusion phassenger的指南https://github.com/phusion/passenger/wiki/Debugging-application-startup-problems
供将来参考:我的配置中的数据库凭据错误,导致相同的错误。