嗨sidekiq / ruby / redis专家:
我不确定这个问题是否与sidekiq,redis,ruby甚至是rails有关。
我们正在尝试在我们的开发服务器上启动sidekiq(实际上距离prod一步,因此我们在prod模式下使用rails),并且sidekiq日志不断产生错误消息:
获取消息时出错:无效参数 - 连接(2)
日志的相关部分如下:
# Logfile created on 2014-04-30 15:57:05 -0400 by logger.rb/31641
Running in ruby 1.9.3p484 (2013-11-22) [i386-mingw32]
See LICENSE and the LGPL-3.0 for licensing details.
Starting processing, hit Ctrl-C to stop
{:queues=>["default"], :concurrency=>25, :require=>".", :environment=>"production", :timeout=>8, :error_handlers=>[#<Sidekiq::ExceptionHandler::Logger:0xef8410>], :lifecycle_events=>{:startup=>[], :quiet=>[], :shutdown=>[]}, :strict=>true, :tag=>"price_tracker_rewrite"}
Booting Sidekiq 3.0.0 with redis options {}
Error fetching message: Invalid argument - connect(2)
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:129:in `connect_nonblock'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:129:in `rescue in connect_addrinfo'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:121:in `connect_addrinfo'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:162:in `block in connect'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:160:in `each'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:160:in `each_with_index'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:160:in `connect'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/connection/ruby.rb:211:in `connect'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/client.rb:285:in `establish_connection'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/client.rb:79:in `block in connect'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/client.rb:257:in `with_reconnect'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/client.rb:78:in `connect'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/client.rb:240:in `with_socket_timeout'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis/client.rb:178:in `call_with_timeout'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis.rb:1038:in `block in _bpop'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis.rb:37:in `block in synchronize'
E:/Rewrite/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis.rb:37:in `synchronize'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis.rb:1035:in `_bpop'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/redis-3.0.7/lib/redis.rb:1080:in `brpop'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/sidekiq-3.0.0/lib/sidekiq/fetch.rb:101:in `block in retrieve_work'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/connection_pool-2.0.0/lib/connection_pool.rb:58:in `with'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/sidekiq-3.0.0/lib/sidekiq.rb:69:in `redis'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/sidekiq-3.0.0/lib/sidekiq/fetch.rb:101:in `retrieve_work'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/sidekiq-3.0.0/lib/sidekiq/fetch.rb:36:in `block in fetch'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/sidekiq-3.0.0/lib/sidekiq/util.rb:15:in `watchdog'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/sidekiq-3.0.0/lib/sidekiq/fetch.rb:32:in `fetch'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
E:/Rewrite/Ruby193/lib/ruby/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'
我的同事&amp;我真的无处可去,谷歌没有任何帮助。谢谢你的帮助!
更新:我正在使用以下行执行sidekiq:“sidekiq -e production”,因为这基本上是我们产品的镜像。我也没有sidekiq配置文件(sidekiq.yml),也许我需要一个?真的不确定,但在测试期间它对我们没有任何障碍。我们也在Windows环境中执行sidekiq,以防万一。
答案 0 :(得分:0)
首先设置一些初始化器,尝试这些(注意Heroku ENV var可以用其他东西替换)
配置/ redis.rb
module MyApp
class << self
def redis
@redis ||= Redis.new(url: (ENV['REDISTOGO_URL'] || 'redis://127.0.0.1:6379'))
end
def sidekiq?
begin
redis_info = Sidekiq.redis { |conn| conn.info }
true
rescue
false
end
end
end
end
配置/ sidekiq.rb
Sidekiq.configure_server do |config|
Rails.logger = Sidekiq::Logging.logger
config.redis = { :url => MyApp.redis[:url], :namespace => 'sidekiq', :size => 5 }
end
Sidekiq.configure_client do |config|
config.redis = { :url => MyApp.redis[:url], :namespace => 'sidekiq', :size => 1 }
end
答案 1 :(得分:0)
这看起来像是一个更基本的Ruby / windows问题。如果可能的话,升级您的MRI版本,或者给JRuby一个镜头。