2014-09-02 79 views
2

我在共享的Dreamhost服务器上安装了ruby 2.1.2和rails 4.1.5。我成功地通过遵循this guide设法使用fcgi部署了一个裸机应用程序。然后我尝试部署一个我以前使用capistrano 3开发的应用程序。cap production deploy工作正常,rails console production也是如此。使用fcgi将rails应用程序部署调试到Dreamhost

问题是,每当我尝试去我的应用程序的网址,我得到一个500错误,只是说“Rails应用程序未能正常启动”。我尝试了以下this other guide进行故障排除,但我并没有走得太远。

至于我可以告诉大家,我的公开/ dispatch.fcgi文件似乎是工作的罚款:

#!/home/myuser/.ruby/bin/ruby 

ENV['RAILS_ENV'] = 'production' 
ENV['HOME'] ||= `echo ~`.strip 
ENV['GEM_HOME'] = File.expand_path('~/.gems') 
ENV['GEM_PATH'] = File.expand_path('~/.gems') 

require 'fcgi' 
require File.join(File.dirname(__FILE__), '../config/environment.rb') 

class Rack::PathInfoRewriter 
    def initialize(app) 
    @app = app 
    end 
    def call(env) 
    env.delete('SCRIPT_NAME') 
    parts = env['REQUEST_URI'].split('?') 
    env['PATH_INFO'] = parts[0] 
    env['QUERY_STRING'] = parts[1].to_s 
    @app.call(env) 
    end 
end 
Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(MyApp::Application) 

我试图运行文件本身,我只能得到一个提示,没有错误(这似乎意味着该应用程序是好的)。

我的日志/ production.log文件是空的。我的服务器日志只显示几行无用消息[Mon Sep 01 17:45:14 2014] [error] [client 201.246.73.121] Premature end of script headers: dispatch.fcgi,它至少告诉我dispatch.fcgi正在被调用。只有谷歌搜索告诉我,我可能会丢失的fcgi宝石,但事实并非如此:

$ bundle show fcgi 
/home/myuser/.gems/gems/fcgi-0.9.2.1 

以防万一,这是我的Gemfile,不包括测试和生产environmens:

source 'https://rubygems.org' 
ruby '2.1.2' 
gem 'therubyracer' 
gem 'fcgi' 
gem 'mysql' 
gem 'rails', '4.1.2' 
gem 'sass-rails', '~> 4.0.3' 
gem 'uglifier', '>= 1.3.0' 
gem 'coffee-rails', '~> 4.0.0' 
gem 'jquery-rails' 
gem 'turbolinks' 
gem 'jbuilder', '~> 2.0' 
gem 'sdoc', '~> 0.4.0',   group: :doc 
gem 'spring',  group: :development 
gem 'bootstrap-sass' 
gem 'high_voltage' 
gem 'slim-rails' 
gem 'savon', '~> 2.5.1' 
gem 'spreadsheet', '~> 0.9.7' 

任何如何调试这个想法? 谢谢

+0

我刚刚碰到这个确切的问题,有没有任何解决方案? – chills42 2014-11-10 04:19:12

回答

2

我今天有这个问题 - 很难理解dispatch.fcgi出了什么问题。在您的浏览器中出现“Rails应用程序无法正常启动”错误以及日志中的“脚本标题提前结束:dispatch.fcgi”错误。

如果你走这条线在dispatch.fcgi:

Rack::Handler::FastCGI.run Rack::PathInfoRewriter.new(MyApp::Application) 

...以及与这些行替换为:

wrappedApp = Rack::Builder.new do 
    use Rack::ShowExceptions 
    use Rack::PathInfoRewriter 
    run MyApp::Application 
end 
Rack::Handler::FastCGI.run wrappedApp 

...然后你会得到的描述性错误时的页面你从应用中加载一个页面。这应该使你能够弄清楚实际问题是什么。