Heroku:空闲导致Rails应用程序崩溃?

时间:2016-01-19 16:46:19

标签: ruby-on-rails heroku unicorn

我正在试图弄清楚导致Rails应用程序崩溃的原因是代码H10,到目前为止找不到解释。

你能帮我找一解吗?

将来如何防止同样的错误?

以下是log:

的片段
# config/unicorn.rb

worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout Integer(ENV['WEB_TIMEOUT'] || 15)
preload_app true

before_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end  

after_fork do |server, worker|

  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

./config/unicorn.rb的内容

var query = 
    db.Sales.Where(x => x.Date.Year == year 
                        && x.Date.Month == month)
            .OrderBy(x => x.Date)
            .Select(g => new
            {
                Day = g.Date.Day,
                Total = g.GrandTotal
            });

这个配置可能导致H10错误吗?

1 个答案:

答案 0 :(得分:0)

这是您最近部署到heroku的新应用吗?你有没有运行迁移?确保在Gemfile中声明了所有依赖项。如果你需要代码中的一些gem,但它不在Gemfile中,它会在Heroku启动时崩溃,即使它在你的本地机器上工作,因为你可能安装了gem并且它可用但是heroku不会有它它在Gemfile中。发出此错误的端点是/feeds/articles开始查看。