应用程序一直崩溃 - Heroku



我对Heroku有问题。一段时间一切都很好,但后来应用程序开始一直崩溃。没有任何可能导致此类行为的更改。以下是 heroku 日志所说的:

2013-12-24T13:02:33.056291+00:00 heroku[web.1]: State changed from crashed to starting
2013-12-24T13:02:39.813510+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -c ./config/unicorn.rb`
2013-12-24T13:02:41.529872+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:5:in `require': cannot load such     file -- rack (LoadError)
2013-12-24T13:02:41.529872+00:00 app[web.1]:  from /app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:5:in `<top (required)>'
2013-12-24T13:02:41.529872+00:00 app[web.1]:  from /app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/launcher.rb:9:in `require'
2013-12-24T13:02:41.529872+00:00 app[web.1]:  from /app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/bin/unicorn:3:in `require'
2013-12-24T13:02:41.529872+00:00 app[web.1]:  from /app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/lib/unicorn/launcher.rb:9:in `<top (    required)>'
2013-12-24T13:02:41.529872+00:00 app[web.1]:  from /app/vendor/bundle/ruby/1.9.1/gems/unicorn-4.6.3/bin/unicorn:3:in `<top (required)>'
2013-12-24T13:02:41.529872+00:00 app[web.1]:  from /app/vendor/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
2013-12-24T13:02:41.529872+00:00 app[web.1]:  from /app/vendor/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'
2013-12-24T13:02:42.643135+00:00 heroku[web.1]: Process exited with status 1
2013-12-24T13:02:42.658659+00:00 heroku[web.1]: State changed from starting to crashed

如果我尝试让 heroku 运行 rake db:migrate,我会得到这个:

/app/vendor/bundle/ruby/1.9.1/bin/rake:23:in `load': cannot load such file --      /app/vendor/bundle/ruby/1.9.1/specifications/bin/rake (LoadError)
from /app/vendor/bundle/ruby/1.9.1/bin/rake:23:in `<main>'

在 heroku 运行轨道 c 之后,我得到这个:

/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails.rb:14:in `require': cannot load such file -- action_dispatch/railtie (LoadError)
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails.rb:14:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/all.rb:1:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/all.rb:1:in `<top (required)>'
from /app/config/application.rb:3:in `require'
from /app/config/application.rb:3:in `<top (required)>'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:39:in `require'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

如果有人能帮忙,那就太好了。谢谢!

上级:这是我的config/unicorn.rb:

timeout 30
preload_app true
worker_processes Integer(ENV['UNICORN_WORKERS'] || 3)
listen ENV['PORT'], :backlog => Integer(ENV['UNICORN_BACKLOG'] || 16)
before_fork do |server, worker|
  if defined?(ActiveRecord::Base)
    ActiveRecord::Base.connection.disconnect!
    Rails.logger.info('Disconnected from ActiveRecord')
  end
  sleep 1
end
after_fork do |server, worker|
  if defined?(ActiveRecord::Base)
    ActiveRecord::Base.establish_connection
    Rails.logger.info('Connected to ActiveRecord')
  end
end

这是我的Procfile:

web: bundle exec unicorn -c ./config/unicorn.rb

我认为您的Procfile配置不正确。 根据 Heroku 独角兽文档,我认为您还需要在Procfile中定义端口。

这是我在独角兽上运行良好的unicorn.rb文件,以及相应的Procfile

# 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

Procfile

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

相关内容

  • 没有找到相关文章

最新更新