Redis early access
Closed this issue · 2 comments
I've found a bug with Sidekiq Worker and Redis :
If Redis is listening on something else than localhost
Sidekiq Worker will fail to start with an error : Socket::ConnectError: Error connecting to 'localhost:6379': Connection refused
I tried to configure it manually with :
# Create CLI
cli = Sidekiq::CLI.new
# Create worker
worker = cli.create
worker.redis = Sidekiq::RedisConfig.new(**redis_config)
but it breaks at worker = cli.create
and worker.redis = Sidekiq::RedisConfig.new(**redis_config)
is never reached.
It thinks it's due to https://github.com/mperham/sidekiq.cr/blob/master/src/sidekiq/server/server.cr#L40 which creates a Pool
which creates a RedisConfig
with default values that cannot work.
I know it can be worarounded by using env vars but what if I don't want to use it? (I already have a configuration file for my application)
I see... an API like Sidekiq.configure_server(&block)
that exists in Ruby or something else is missing.
The current workaround as you said is using the env var, OTOH this issue is easy to fix.
I just noticed that this is already implemented, just not documented, so I just add the code to do the redis configuration to the example, basically you do:
cli = Sidekiq::CLI.new
server = cli.configure do |config|
config.redis = Sidekiq::RedisConfig.new("localhost", 6379)
end
cli.run(server)