2014-04-06 4 views
2

레일즈를 사용하여 레일리에 아주 이상한 문제가 있습니다.레일즈는 모든 요청을 두 번 처리합니다.

모든 단일 요청이 두 번 처리 중입니다. 단일 CURL 요청도 두 번 처리되므로 AJAX에서는 문제가되지 않습니다. 로그가 문제가되는 것은 아니며 액션은 실제로 두 번 발생합니다.

문제는 Heroku 및 로컬에서 모두 프로덕션 환경에서만 발생합니다.

예 로그 :

2014-04-06T06:45:48.969394+00:00 heroku[router]: at=info method=POST path=/spree/api/orders/R657018514/line_items host=xxx.xxx.com request_id=75ac3584-f33e-48fe-b6ce-d898120f8b57 fwd="185.12.21.77" dyno=web.1 connect=0ms service=399ms status=201 bytes=1097 
2014-04-06T06:45:48.952672+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.0.0/bundler/gems/spree-78f129b6d6f5/api/app/views/spree/api/orders/show.v1.rabl (120.9ms) 
2014-04-06T06:45:48.959453+00:00 app[web.1]: Completed 201 Created in 381ms (Views: 93.4ms | ActiveRecord: 188.8ms) 
2014-04-06T06:45:48.959460+00:00 app[web.1]: Completed 201 Created in 381ms (Views: 93.4ms | ActiveRecord: 188.8ms) 
2014-04-06T06:45:48.958355+00:00 app[web.1]: Rendered vendor/bundle/ruby/2.0.0/bundler/gems/spree-78f129b6d6f5/api/app/views/spree/api/orders/show.v1.rabl (120.9ms) 

Started GET "/" for 127.0.0.1 at 2014-04-06 08:55:29 +0200 
Started GET "/" for 127.0.0.1 at 2014-04-06 08:55:29 +0200 
Processing by Spree::HomeController#index as HTML 
Processing by Spree::HomeController#index as HTML 
    Rendered spree/home/index.html.erb within spree/layouts/spree_application (0.8ms) 
    Rendered spree/home/index.html.erb within spree/layouts/spree_application (0.8ms) 

Gemfile.rb :

source 'https://rubygems.org' 

gem 'rails', '4.0.3' 

gem 'newrelic_rpm' 

group :assets do 
    gem 'sass-rails', '~> 4.0.0' 
    gem 'coffee-rails', '~> 4.0.0' 
    gem 'compass',      '= 0.12.2' 
    gem 'compass-rails',    '~> 1.1.2' 
    gem 'uglifier', '>= 1.0.3' 
end 

group :development do 
    gem 'sqlite3' 
    gem 'pry-rails' 
end 

group :production do 
    gem 'pg' 
    gem 'rails_12factor' 
end 

gem 'jquery-rails', '~> 3.1.0' 
gem 'jquery-ui-rails' 

gem 'handlebars_assets' 

gem 'spree', :github => "methyl/spree", :require => false 
gem 'spree_auth_devise', github: 'spree/spree_auth_devise' 

production.rb

Aimer::Application.configure do 
    # Settings specified here will take precedence over those in config/application.rb 

    # Code is not reloaded between requests 
    config.cache_classes = true 

    # Full error reports are disabled and caching is turned on 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 

    # Disable Rails's static asset server (Apache or nginx will already do this) 
    config.serve_static_assets = true 
    config.static_cache_control = "public, max-age=31536000" 

    # Compress JavaScripts and CSS 
    config.assets.compress = true 

    # Don't fallback to assets pipeline if a precompiled asset is missed 
    config.assets.compile = true 

    # Generate digests for assets URLs 
    config.assets.digest = true 

    config.assets.js_compressor = :uglifier 
    config.assets.css_compressor = :sass 

    # Defaults to nil and saved in location specified by config.assets.prefix 
    # config.assets.manifest = YOUR_PATH 

    # Specifies the header that your server uses for sending files 
    # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache 
    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx 

    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 
    config.force_ssl = false 

    # See everything in the log (default is :info) 
    # config.log_level = :debug 

    # Prepend all log lines with the following tags 
    # config.log_tags = [ :subdomain, :uuid ] 

    # Use a different logger for distributed setups 
    # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) 

    # Use a different cache store in production 
    # config.cache_store = :mem_cache_store 

    # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) 
    # config.assets.precompile += %w(search.js) 

    # Disable delivery errors, bad email addresses will be ignored 
    # config.action_mailer.raise_delivery_errors = false 

    # Enable threaded mode 
    # config.threadsafe! 

    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 
    # the I18n.default_locale when a translation can not be found) 
    config.i18n.fallbacks = true 

    # Send deprecation notices to registered listeners 
    config.active_support.deprecation = :notify 

    # Log the query plan for queries taking more than this (works 
    # with SQLite, MySQL, and PostgreSQL) 
    # config.active_record.auto_explain_threshold_in_seconds = 0.5 
end 
+1

로그가 아님을 어떻게 알 수 있습니까? 정확히 동일한 렌더링 시간으로 2 개의 요청을하는 것은 매우 불가능합니다. 모든 요청의 경우입니까? – Giannis

+0

이메일을 두 번받습니다. 요청할 때마다 AFAIK입니다. – methyl

+0

로그 항목이 똑같은 처리 시간을 보이고있을뿐 아니라 2 초가 서로 7 마이크로 초 내에 기록되었습니다. 문제가 무엇이든, 표시된 코드는 그것을 다루지 않습니다. 아마도 두 번 등록하기 때문에 실수로 일부 미들웨어 구성 요소에 대한 이중 호출을 의심 할 수 있습니다. –

답변

1

@Giannis, 당신이 옳았, 로그 만 중복되고, 원인 이중 이메일은 어딘가에, 아마 Sendgrid 설정에 있었다.

1

아마 전에 heroku를 사용하고 있었고 나중에 배포를 위해 다른 인스턴스를 사용하기 시작했습니다.

gem 'rails_12factor' 번 의견을 한번 쓰고 번들 설치를 한 번 한 번 확인하십시오.

관련 문제