2

rails + unicorn + nginxおよび を使用しcapistranoて展開するアプリケーションがあります。

昨日バンドルの更新を実行するまで、すべて正常に機能していました。メソッドが見つからないため、ユニコーンサーバーが突然起動できなくなりました。generated_attribute_methods

開発中は問題なくサーバーを起動して使用できますが、本番環境ではこのエラーが発生します

これは、rvm (本番) を使用する私のマシンからのサーバー起動からの出力です。

I, [2013-05-14T10:05:59.070825 #52560]  INFO -- : Refreshing Gem list
/Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing': undefined local variable or method `generated_attribute_methods' for #<Class:0x007fe254b1fe98> (NameError)
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/base.rb:405:in `initialize_generated_modules'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/base.rb:397:in `inherited'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/session_store.rb:79:in `<class:SessionStore>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/session_store.rb:53:in `<module:ActiveRecord>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/session_store.rb:3:in `<top (required)>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/configuration.rb:138:in `session_store'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:273:in `block in default_middleware_stack'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:237:in `tap'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:237:in `default_middleware_stack'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/engine.rb:469:in `app'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/finisher.rb:31:in `block in <module:Finisher>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/nicoskaralis/Documents/WayTaxi/webapp/config/environment.rb:5:in `<top (required)>'
    from config.ru:4:in `require'
    from config.ru:4:in `block in <main>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1:in `<main>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:140:in `start'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/bin/unicorn:19:in `load'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/bin/unicorn:19:in `<main>'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/nicoskaralis/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'

これは、rbenv (プロダクション) を使用して、私のサーバーからサーバーを開始したときの出力です。

I, [2013-05-14T10:14:14.599183 #25840]  INFO -- : Refreshing Gem list
/home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in `method_missing': undefined local variable or method `generated_attribute_methods' for #<Class:0x0000000204fe50> (NameError)
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/base.rb:405:in `initialize_generated_modules'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/base.rb:397:in `inherited'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/session_store.rb:79:in `<class:SessionStore>'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/session_store.rb:53:in `<module:ActiveRecord>'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/session_store.rb:3:in `<top (required)>'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/configuration.rb:138:in `session_store'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:273:in `block in default_middleware_stack'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:237:in `tap'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:237:in `default_middleware_stack'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:469:in `app'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:31:in `block in <module:Finisher>'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/deployer/rails_apps/webapp/releases/20130514130605/config/environment.rb:5:in `<top (required)>'
    from config.ru:4:in `require'
    from config.ru:4:in `block in <main>'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1:in `<main>'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:140:in `start'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
    from /home/deployer/rails_apps/webapp/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'

カピストラーノでルビー1.9.3-p392を使用するように設定したため、これは奇妙ですが、ubuntuであり、機能していたため、これがどのように問題になるかわかりません

ここで何が問題なのですか?私は何をすべきか?

編集

必要に応じてconfig.ru

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
run Webapp::Application

編集2

サーバーを起動するために使用しているコマンドは、基本的に次のとおりです。

bundle exec unicorn -p 3000 -c ./config/unicorn.rb -E production

そして、私がに変更した場合

bundle exec unicorn_rails -l 0.0.0.0:3000 -E production

それは機能しますが、サーバー内に構成を入れていません。さらに、unicorn_railsもう使用すべきではないことを読みました

編集3

どうやら私の問題は内部にありますWebapp::Application.initialize!

puts "before" # => prints
Webapp::Application.initialize!
puts "after" # => don't prints

編集 4 15/05

私は他のマシンと私のサーバー(ubuntu 10.04)と私のマシン(mac os x)でテストしていましたが、サーバーが起動せず、そのエラーが発生しました。しかし、同僚のマシン (ubuntu 12.04) では問題なく動作します。

そして、いくつかのテストの後、開発コードをクリーンアップし、git から最新バージョンをダウンロードすることにしました。今では正常に動作することもあれば、エラーが発生することもあります。

どうなり得るか?

編集5

どうやらこれは new relic + unicorn が原因で、次の行にコメントしています:

if defined? Unicorn
  ::NewRelic::Agent.manual_start()
  ::NewRelic::Agent.after_fork(:force_reconnect => true)
end

すべてを正常に動作させる

4

0 に答える 0