redis - 在 sidekiq 容器中设置 redis 配置选项

标签 redis sidekiq

我刚刚在最新的 docker 容器上运行了 docker-compose build,我注意到 sidekiq 现在正在重复生成这一行:

sidekiq_1   | `Redis#exists(key)` will return an Integer in redis-rb 4.3. `exists?` returns a boolean, you should use it instead. To opt-in to the new behavior now you can set Redis.exists_returns_integer =  true. To disable this message and keep the current (boolean) behaviour of 'exists' you can set `Redis.exists_returns_integer = false`, but this option will be removed in 5.0. (/usr/local/bundle/gems/sidekiq-6.0.7/lib/sidekiq/launcher.rb:160:in `block (2 levels) in ❤')

我到底在哪里设置这个设置?我尝试创建一个初始化程序,但我确信我做错了:

# config/initializers/sidekiq.rb
redis_conn = proc {
  Redis.exists_returns_integer =  true
}

Sidekiq.configure_client do |config|
  config.redis = ConnectionPool.new(size: 5, &redis_conn)
end

Sidekiq.configure_server do |config|
  config.redis = ConnectionPool.new(size: 25, &redis_conn)
end

尝试使用上面初始化程序中的代码时,容器因以下错误而失败:

sidekiq_1   | 2020-06-17T02:42:21.743Z pid=1 tid=gshym9ynx INFO: Booted Rails 5.2.4 application in development environment
sidekiq_1   | 2020-06-17T02:42:21.743Z pid=1 tid=gshym9ynx INFO: Running in ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
sidekiq_1   | 2020-06-17T02:42:21.743Z pid=1 tid=gshym9ynx INFO: See LICENSE and the LGPL-3.0 for licensing details.
sidekiq_1   | 2020-06-17T02:42:21.743Z pid=1 tid=gshym9ynx INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org
sidekiq_1   | undefined method `info' for true:TrueClass
sidekiq_1   | /usr/local/bundle/gems/sidekiq-6.0.7/lib/sidekiq.rb:118:in `block in redis_info'
sidekiq_1   | /usr/local/bundle/gems/sidekiq-6.0.7/lib/sidekiq.rb:97:in `block in redis'
sidekiq_1   | /usr/local/bundle/gems/connection_pool-2.2.3/lib/connection_pool.rb:63:in `block (2 levels) in with'
sidekiq_1   | /usr/local/bundle/gems/connection_pool-2.2.3/lib/connection_pool.rb:62:in `handle_interrupt'
sidekiq_1   | /usr/local/bundle/gems/connection_pool-2.2.3/lib/connection_pool.rb:62:in `block in with'
sidekiq_1   | /usr/local/bundle/gems/connection_pool-2.2.3/lib/connection_pool.rb:59:in `handle_interrupt'
sidekiq_1   | /usr/local/bundle/gems/connection_pool-2.2.3/lib/connection_pool.rb:59:in `with'
sidekiq_1   | /usr/local/bundle/gems/sidekiq-6.0.7/lib/sidekiq.rb:94:in `redis'
sidekiq_1   | /usr/local/bundle/gems/sidekiq-6.0.7/lib/sidekiq.rb:112:in `redis_info'
sidekiq_1   | /usr/local/bundle/gems/sidekiq-6.0.7/lib/sidekiq/cli.rb:61:in `run'
sidekiq_1   | /usr/local/bundle/gems/sidekiq-6.0.7/bin/sidekiq:31:in `<top (required)>'
sidekiq_1   | /usr/local/bundle/bin/sidekiq:23:in `load'
sidekiq_1   | /usr/local/bundle/bin/sidekiq:23:in `<top (required)>'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:74:in `load'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:74:in `kernel_load'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:28:in `run'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:463:in `exec'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:27:in `dispatch'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:18:in `start'
sidekiq_1   | /usr/local/bin/bundle:30:in `block in <main>'
sidekiq_1   | /usr/local/lib/ruby/site_ruby/2.5.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
sidekiq_1   | /usr/local/bin/bundle:22:in `<main>'
test_sidekiq_1 exited with code 1

最佳答案

sidekiq github 上有一个与此问题相关的问题。

您可以在这里看到:https://github.com/mperham/sidekiq/issues/4591

基本上,redis gem 进行了一项更改,今后在使用某种方法时将导致不同的行为。在 Sidekiq 6.1 发布之前,除了暂时降级您正在使用的 redis gem 版本之外,您无法采取任何措施来抑制此消息。

我目前将其保存在 Gemfile 中,以避免收到此消息的垃圾邮件。

gem 'redis', '4.1.4'

问题不在于你正在做的任何事情,而在于你正在使用的库。

关于redis - 在 sidekiq 容器中设置 redis 配置选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62420602/

相关文章:

node.js - 使用 redis 作为数据库使用 nodeJS

ruby - 如何从 sidekiq 队列中删除特定类别的作业?

php - Laravel 5.1 Session 和 Socket.IO + Redis - 向登录(已知)用户和用户组发送通知

node.js - Catbox-redis 在我的 hapijs 应用程序上显示断开连接错误

ruby-on-rails - 如何在 rspec 中使用 sidekiq 禁用警告消息

ruby-on-rails - 在 Rails 应用程序中异步执行存储过程

ruby-on-rails - Sidekiq 仅在生产环境中重试

nginx - Ruby On Rails : Mailer : Sidekiq - asset path not valid in email : Engineyard : Nginx : Passenger

c++ - 空闲期后 Redis PUBSUB 连接问题

memcached - 可扩展对象的键值存储