Search code examples
ruby-on-railsredissidekiq

Sidekiq in development environment


I have a longstanding project that is using sidekiq with redis and a problem that has started I believe only since upgrading to sidekiq 3+.

The problem is that I can't run my rails (4.1.4) app in development without first starting a redis server. I get the same error starting the rails server as I get when I try to run bundle exec sidekiq without first starting redis. Running my rails app without redis running was never a problem before, even though sidekiq was setup the same way.

Can someone suggest a way around having to start a redis server even when I don't intend to run sidekiq?

Here is the backtrace:

/Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:309:in

rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED) (Redis::CannotConnectError) from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:304:in establish_connection' from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:85:in block in connect' from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:266:in with_reconnect' from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:84:in connect' from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:326:in ensure_connected' from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:197:in block in process' from /Users/mark/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/redis-3.1.0/lib/redis/client.rb:279:in logging' from


Solution

  • I think this problem is related to https://github.com/tobiassvn/sidetiq/issues/103.

    Unfortunately, the fix has not been pulled into the main repo yet. You can try using the fixed fork in your Gemfile to see if it fixes the problem:

    gem 'sidetiq', github: 'nkondratyev/sidetiq', branch: 'fix_working_with_prefork_servers'