不能对流浪者运行sidekiq

时间:2017-07-15 03:55:05

标签: ruby-on-rails ruby redis vagrant sidekiq

我正在使用Ruby on Rails开发一个Web应用程序,我希望用deliver_later发送电子邮件。

Gemfilegem sidekiqconfig/initializer/sidekiq.rb中,

redis_sec = { host: '127.0.0.1' }
Sidekiq.configure_client do |config|
  config.redis = { url: "redis://#{redis_sec[:host]}:6379", namespace: 'sidekiq' }
end
Sidekiq.configure_server do |config|
  config.redis = { url: "redis://#{redis_sec[:host]}:6379", namespace: 'sidekiq' }
end

最后,在config/sidekiq.yml

:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log

我在app/workers/worker_for_sidekiq.rb中编写了一个测试sidekiq队列:

class WorkerForSidekiq
  include Sidekiq::Worker
  sidekiq_options queue: :sidekiq
  def perform(text)
    sleep 5
    p text
  end
end

然后,对于vagrant在bundle exec sidekiq -q sidekiq上运行sidekiq会出错:

ERR Syntax error, try CLIENT (LIST | KILL ip:port)
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:121:in `call'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-4.2.0.334/lib/new_relic/agent/instrumentation/redis.rb:69:in `call'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:104:in `block in connect'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:293:in `with_reconnect'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:100:in `connect'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-4.2.0.334/lib/new_relic/agent/instrumentation/redis.rb:105:in `connect'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:364:in `ensure_connected'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:221:in `block in process'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:306:in `logging'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:220:in `process'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis/client.rb:120:in `call'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-4.2.0.334/lib/new_relic/agent/instrumentation/redis.rb:69:in `call'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis.rb:251:in `block in info'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/redis-3.3.3/lib/redis.rb:250:in `info'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.3/lib/sidekiq.rb:111:in `block in redis_info'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.3/lib/sidekiq.rb:95:in `block in redis'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/connection_pool-2.2.1/lib/connection_pool.rb:64:in `block (2 levels) in with'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/connection_pool-2.2.1/lib/connection_pool.rb:63:in `handle_interrupt'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/connection_pool-2.2.1/lib/connection_pool.rb:63:in `block in with'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/connection_pool-2.2.1/lib/connection_pool.rb:60:in `handle_interrupt'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/connection_pool-2.2.1/lib/connection_pool.rb:60:in `with'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.3/lib/sidekiq.rb:92:in `redis'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.3/lib/sidekiq.rb:106:in `redis_info'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.3/lib/sidekiq/cli.rb:81:in `run'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-5.0.3/bin/sidekiq:12:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.3.0/bin/sidekiq:23:in `load'
/home/vagrant/.rbenv/versions/2.3.0/bin/sidekiq:23:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `load'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/cli/exec.rb:27:in `run'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/cli.rb:335:in `exec'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/cli.rb:20:in `dispatch'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/cli.rb:11:in `start'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/exe/bundle:32:in `block in <top (required)>'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/exe/bundle:24:in `<top (required)>'
/home/vagrant/.rbenv/versions/2.3.0/bin/bundle:23:in `load'
/home/vagrant/.rbenv/versions/2.3.0/bin/bundle:23:in `<main>'

所以,我尝试reids-cliCLIENT LIST

redis 127.0.0.1:6379> CLIENT LIST
addr=127.0.0.1:49802 fd=5 idle=0 flags=N db=0 sub=0 psub=0 qbuf=0 obl=0 oll=0 events=r cmd=client

我完全按照this Japanese blog的说明操作。我搜索了一些关键字,例如&#39; sidekiq语法错误,&#39; &#39; sidekiq vagrant error,&#39; &#39; sidekiq virtualbox,&#39;和&#39; sidekiq客户名单,&#39;但没有找到有用的文章。

有什么问题?在流浪汉上没有sidekiq吗?

  • macOS Sierra 10.12.5
  • vagrant 1.9.4
  • centos64(vagrant)
  • ruby​​ 2.3.0p0
  • Rails 5.1.1
  • Bundler 1.14.6

的Gemfile:

gem 'sidekiq'
gem 'redis', '3.3.3'
gem 'redis-rails'
gem 'redis-namespace'

1 个答案:

答案 0 :(得分:0)

查看堆栈跟踪,错误似乎来自this block

with_reconnect(false) do
  establish_connection
  call [:auth, password] if password
  call [:select, db] if db != 0
  call [:client, :setname, @options[:id]] if @options[:id]
  @connector.check(self)
end

特别注意这一行:

call [:client, :setname, @options[:id]] if @options[:id]

CLIENT SETNAME命令仅适用于Redis 2.6.9。如果您尝试使用旧版本运行它,则会收到您看到的错误消息。

解决方案是将Redis升级到至少2.6.9。