【发布时间】:2013-12-24 13:19:30
【问题描述】:
我遇到了 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 run rails 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>'
如果有人可以提供帮助,那就太好了。谢谢!
更新: 这是我的配置/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
【问题讨论】:
-
嘿,你有一个 config/unicorn.rb 文件,对吧?都设置好了?
-
如果你运行 webrick 一切都好吗?
-
是的,用 webrick 一切正常
标签: ruby-on-rails heroku unicorn