2016-12-01 13 views
-1

Resque.enqueuを使用してRedisとredistogoを使用してバックグラウンドジョブをスケジュールするrarokuのアプリがあります。Heroku、Rails、Resque、Redis:Errno :: ETIMEDOUTのためにすべてのジョブが失敗する

ジョブは正常に動作していましたが、しばらくの間(数週間、100%のジョブ)失敗しています。

私が取得エラー:

例外はerrno :: ETIMEDOUTエラー接続がタイムアウト - 接続(2)

およびスタックトレース:

> /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878:in `initialize' 
> /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878:in `open' 
> /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878:in `block in 
> connect' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/timeout.rb:52:in 
> `timeout' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:877:in 
> `connect' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:862:in 
> `do_start' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:851:in 
> `start' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1373:in 
> `request' /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1131:in 
> `get' 
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:121:in `block in request' 
> /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in 
> `block in instrument' 
> /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20:in 
> `instrument' 
> /app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164:in 
> `instrument' 
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:118:in `request' 
> /app/vendor/bundle/ruby/2.0.0/gems/shopify_api-4.0.6/lib/active_resource/connection_ext.rb:13:in `request_with_detailed_log_subscriber' 
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:82:in 
> `block in get' 
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:216:in `with_auth' 
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/connection.rb:82:in 
> `get' 
> /app/vendor/bundle/ruby/2.0.0/gems/activeresource-4.0.0/lib/active_resource/custom_methods.rb:57:in 
> `get' 
> /app/vendor/bundle/ruby/2.0.0/gems/shopify_api-4.0.6/lib/shopify_api/countable.rb:4:in 
> `count' /app/app/models/shop.rb:263:in `unscanned_customers' 
> /app/app/models/shop.rb:230:in `shopify_customers' 
> /app/app/models/shop.rb:144:in `bulk_scan' 
> /app/app/workers/bulk_scanner.rb:16:in `perform' 

私が考えていましたおそらく、Redisに接続したり、適切にredistogoに接続しないことと関係があるでしょう。ここで私が持っている、関連する初期化コードを、次のとおりです。

resque.rb:

Resque.redis = RedisConnection.connection 

redis_connection.rb:

class RedisConnection 
    def self.close 
    connection.quit 
    end 

    def self.connection 
    @connection ||= new_connection 
    end 

    def self.new_connection 
    uri = URI.parse(ENV['REDISTOGO_URL'] || 'redis://localhost:6379/') 

    Redis.new(host: uri.host, 
       port: uri.port, 
       password: uri.password, 
       thread_safe: true, 
       :timeout => 1) 
    end 
end 

私は私のアプリでResque.redisまたは@connectionを呼び出すと、 Redisインスタンスを返します。この接続エラーの原因はほかに何ですか?どこでトラブルシューティングできますか?

答えて

1

Backtraceを見ると、Shopify APIの接続タイムアウトになる可能性がありますか? unscanned_customersは、カウント可能なShopifyコレクションであると思われ、顧客を取得しようとすると問題が発生します。

私はここに私のデバッグを開始します:

shop_url = "https://#{API_KEY}:#{PASSWORD}@SHOP_NAME.myshopify.com/admin" 
ShopifyAPI::Base.site = shop_url 

はShopify APIを参照してください。 > 'count' /app/app/models/shop.rb:263:in 'unscanned_customers'

また、私はプライベートアプリのAPIキーとパスワードを使用して、サーバからShopifyに接続しようとします詳細については、必要に応じてShopify API Readme

これは、接続の問題を特定するのに役立ちます。

乾杯。

関連する問題