config/initializers/sidekiq.rb
Sidekiq.configure_server do |config|
config.redis = { :url => 'redis://192.xxx.xxx.xx:6379/0' }
end
In production console when I do
ActivationWorker.perform_async(877459)
It gives an error
Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
Even sidekiq.log prints
Booting Sidekiq 5.1.3 with redis options {:url=>"redis://192.xxx.xxx.xx:6379/0", :id=>"Sidekiq-server-PID-646"}
It is important to note that to configure the location of Redis, you must define both the Sidekiq.configure_server and Sidekiq.configure_client blocks
So also add to your config/initializers/sidekiq.rb
:
Sidekiq.configure_client do |config|
config.redis = { :url => 'redis://192.xxx.xxx.xx:6379/0' }
end
Also important notes from docs:
NOTE: The configuration hash must have symbolized keys.
NOTE: Unknown parameters are passed to the underlying Redis client so any parameters supported by the driver can go in the Hash.
Based on the comments, we know that Redis is on a separate server.
Create a file in initializers: config/initializers/sidekiq.rb
:
Sidekiq.configure_server do |config|
config.redis = {
url: "redis://192.xxx.xxx.xxx:6379/12"
}
end
Sidekiq.configure_client do |config|
config.redis = {
url: "redis://192.xxx.xxx.xxx:6379/12"
}
end
/etc/redis/redis.conf
bind 192.xxx.xxx.xxx
redis
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.