繁体   English   中英

在Rails 4上设置Unicorn-应用崩溃

[英]Setting up Unicorn on Rails 4 - App Crashes

我正在尝试在Rails 4 / Ruby 2.0应用程序上安装独角兽。 我按照此处 heroku上的说明进行设置。

我以为说明很简单,但是我在mktdemo.herokuapp.com上的应用程序崩溃了。

正在读取我的procfile,因此在heroku仪表板上,我看到独角兽显示为我的服务器。 在heroku(如下)上显示的unicorn.rb是否已过期?

在unicorn.rb中,有一个ENV [WEB_CONCURRENCY]变量。 我需要将它放在yml文件中吗? 我从任何地方都看不到它的提及。

我在我的应用程序上安装了delay_jobs,因此不确定是否与此有关。

#gemfile
gem 'unicorn'

#procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec rake jobs:work

#config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
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 send QUIT'
  end

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

# config/initializers/timeout.rb
Rack::Timeout.timeout = 10  # seconds

这是我的日志中的最后50行左右:

←[36m2014-10-23T02:42:30.064512+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializer
s'
←[36m2014-10-23T02:42:30.064346+00:00 app[web.1]:←[0m   from /app/vendor/ruby-2.
0.0/lib/ruby/2.0.0/
tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
←[36m2014-10-23T02:42:30.064449+00:00 app[web.1]:←[0m   from /app/vendor/ruby-2.
0.0/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
←[36m2014-10-23T02:42:30.064465+00:00 app[web.1]:←[0m   from /app/vendor/ruby-2.
0.0/lib/ruby/2.0.0/tsort.rb:180:in `each'
←[36m2014-10-23T02:42:30.064481+00:00 app[web.1]:←[0m   from /app/vendor/ruby-2.
0.0/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
←[36m2014-10-23T02:42:30.064558+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_m
issing'
←[36m2014-10-23T02:42:30.064427+00:00 app[web.1]:←[0m   from /app/vendor/ruby-2.
0.0/lib/ruby/2.0.0/tsort.rb:203:in `each_strongly_connected_component_from'
←[36m2014-10-23T02:42:30.064608+00:00 app[web.1]:←[0m   from config.ru:4:in `blo
ck in <main>'
←[36m2014-10-23T02:42:30.064528+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
←[36m2014-10-23T02:42:30.064591+00:00 app[web.1]:←[0m   from config.ru:4:in `req
uire'
←[36m2014-10-23T02:42:30.064496+00:00 app[web.1]:←[0m   from /app/vendor/ruby-2.
0.0/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
←[36m2014-10-23T02:42:30.064575+00:00 app[web.1]:←[0m   from /app/config/environ
ment.rb:5:in `<top (required)>'
←[36m2014-10-23T02:42:30.064877+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'
←[36m2014-10-23T02:42:30.064790+00:00 app[web.1]:←[0m   from config.ru:1:in `new
'
←[36m2014-10-23T02:42:30.064892+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:137:in `start'
←[36m2014-10-23T02:42:30.064767+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
←[36m2014-10-23T02:42:30.064630+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
←[36m2014-10-23T02:42:30.064924+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
←[36m2014-10-23T02:42:30.064940+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/bin/unicorn:23:in `load'
←[36m2014-10-23T02:42:30.064830+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'
←[36m2014-10-23T02:42:30.064861+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'
←[36m2014-10-23T02:42:30.064956+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/bin/unicorn:23:in `<main>'
←[36m2014-10-23T02:42:30.064814+00:00 app[web.1]:←[0m   from config.ru:1:in `<ma
in>'
←[36m2014-10-23T02:42:30.064846+00:00 app[web.1]:←[0m   from /app/vendor/bundle/
ruby/2.0.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'
←[36m2014-10-23T02:42:30.897477+00:00 heroku[web.1]:←[0m State changed from star
ting to crashed
←[36m2014-10-23T02:42:30.888021+00:00 heroku[web.1]:←[0m Process exited with sta
tus 1
←[33m2014-10-23T02:44:47.509030+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path="/" host=mktdemo.herokuapp.com request_id=6472e28
f-4ba3-4eed-aa0d-8089c0ddcec4 fwd="67.180.31.102" dyno= connect= service= status
=503 bytes=
←[33m2014-10-23T02:51:07.861451+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path="/" host=mktdemo.herokuapp.com request_id=c792113
3-fdbd-4614-8425-c90115aa2251 fwd="74.86.158.106" dyno= connect= service= status
=503 bytes=
←[33m2014-10-23T03:05:42.246318+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path="/favicon.ico" host=mktdemo.herokuapp.com request
_id=ca8a9d59-9764-4f1c-8b8d-15845c73146e fwd="67.180.31.102" dyno= connect= serv
ice= status=503 bytes=
←[33m2014-10-23T03:05:41.930425+00:00 heroku[router]:←[0m at=error code=H10 desc
="App crashed" method=GET path="/" host=mktdemo.herokuapp.com request_id=dd9b869
8-57c5-4465-810e-f55de098df5e fwd="67.180.31.102" dyno= connect= service= status
=503 bytes=

您似乎没有添加rack-timeout gem。

将其添加到您的Gemfile中:

gem 'rack-timeout'

然后运行bundle install ,签入更新的Gemfile和Gemfile.lock,然后将更改推送到Heroku。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM