我使用dokku,puma,sidekiq和sidkiq-status 有时我有这个错误: 错误消息
NoMethodError: undefined method `multi' for nil:NilClass
Sample stack trace (show Rails)
…ems/sidekiq-status-0.5.4/lib/sidekiq-status/
storage.rb: 16:in `block in store_for_id'
…ems/sidekiq-status-0.5.4/lib/sidekiq-status/
storage.rb: 103:in `block in redis_connection'
….2.0/gems/connection_pool-2.2.0/lib/
connection_pool.rb: 64:in `block (2 levels) in with'
….2.0/gems/connection_pool-2.2.0/lib/
connection_pool.rb: 63:in `handle_interrupt'
….2.0/gems/connection_pool-2.2.0/lib/
connection_pool.rb: 63:in `block in with'
….2.0/gems/connection_pool-2.2.0/lib/
connection_pool.rb: 60:in `handle_interrupt'
….2.0/gems/connection_pool-2.2.0/lib/
connection_pool.rb: 60:in `with'
…ems/sidekiq-status-0.5.4/lib/sidekiq-status/
storage.rb: 102:in `redis_connection'
…ems/sidekiq-status-0.5.4/lib/sidekiq-status/
storage.rb: 15:in `store_for_id'
…ems/sidekiq-status-0.5.4/lib/sidekiq-status/
storage.rb: 32:in `store_status'
…q-status-0.5.4/lib/sidekiq-status/
client_middleware.rb: 11:in `call'
…2.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/
chain.rb: 129:in `block in invoke'
…2.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/
chain.rb: 132:in `call'
…2.0/gems/sidekiq-3.5.4/lib/sidekiq/middleware/
chain.rb: 132:in `invoke'
…le/ruby/2.2.0/gems/sidekiq-3.5.4/lib/sidekiq/
client.rb: 208:in `process_single'
…le/ruby/2.2.0/gems/sidekiq-3.5.4/lib/sidekiq/
client.rb: 65:in `push'
…le/ruby/2.2.0/gems/sidekiq-3.5.4/lib/sidekiq/
worker.rb: 98:in `client_push'
…le/ruby/2.2.0/gems/sidekiq-3.5.4/lib/sidekiq/
worker.rb: 54:in `perform_async'
/app/app/controllers/reports/
report_items_controller.rb: 90:in `params_to_session'
…0/gems/actionview-4.2.5.1/lib/action_view/
rendering.rb: 30:in `process'
Sidekiq失去了redis连接...... 我的Sidekiq.rb
require 'sidekiq'
require 'sidekiq/web'
require 'sidekiq-cron'
require 'sidekiq-status'
Sidekiq.default_worker_options = { backtrace: true, retry: false }
Sidekiq.configure_server do |config|
config.redis = { url: App.redis, size: 20 }
if ENV['DATABASE_URL'].present?
database_url = "#{ENV['DATABASE_URL']}?pool=25"
ActiveRecord::Base.establish_connection(database_url)
else
ActiveRecord::Base.establish_connection
end
config.server_middleware do |chain|
chain.add Sidekiq::Status::ServerMiddleware, expiration: 30.minutes # default
end
config.client_middleware do |chain|
chain.add Sidekiq::Status::ClientMiddleware
end
Sidekiq::Cron::Job.load_from_hash YAML.load_file(Rails.root.join('config', 'sidekiq_cron.yml'))
end
Sidekiq.configure_client do |config|
config.redis = { url: App.redis, size: 2 }
config.client_middleware do |chain|
chain.add Sidekiq::Status::ClientMiddleware
end
end
我的puma.rb
workers Integer(ENV['PUMA_WORKERS'] || 2)
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 32)
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
prune_bundler
on_worker_boot do
if defined?(ActiveRecord::Base)
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.establish_connection
end
Rails.logger.info('Connected to ActiveRecord')
end
if defined?(REDIS)
uri = URI.parse(App.redis)
REDIS = Redis.new(host: uri.host, port: uri.port, password: uri.password)
Rails.logger.info('Connected to Redis')
end
sidekiq_redis = { :url => ENV["REDIS_URL"] }
Sidekiq.configure_server do |config|
config.redis = sidekiq_redis
end
Sidekiq.configure_client do |config|
config.redis = sidekiq_redis
end
end
我该如何解决这个问题?