Jobs never making it into the queue

40 views
Skip to first unread message

Will Green

unread,
Jul 1, 2016, 6:23:48 PM7/1/16
to Sidekiq
So I have a Rails app with the following configuration:

# config/sideqik.yml
---
:verbose: true
:concurrency: 5
:pidfile: tmp/pids/sidekiq.pid
:staging:
  :concurrency: 10
:production:
  :concurrency: 20
:queues:
  - default
  - mailers

# config/initializers/sidekiq.rb
require 'sidekiq/web'

Sidekiq.configure_server do |config|
  config.redis = { url: ENV.fetch('SIDEKIQ_REDIS_URL', 'redis://localhost:6379/12') }
end

Sidekiq.configure_client do |config|
  config.redis = { url: ENV.fetch('SIDEKIQ_REDIS_URL', 'redis://localhost:6379/12') }
end

And I have the following worker:

# app/workers/hard_worker.rb
class HardWorker
  include Sidekiq::Worker
  sidekiq_options queue: 'default', backtrace: 5

  def perform(name, count, salt)
    raise name if name == 'crash'
    logger.info Time.now
    sleep count
  end
end

In one console tab, I run bin/sidekiq. In another tab, I run bin/rails c.

$ bin/rails c
Running via Spring preloader in process 18864
Loading development environment (Rails 4.2.6)
irb: warn: can't alias context from irb_context.
irb(main):001:0> HardWorker.perform_async 'foo', 1, SecureRandom.uuid
=> "b2c69a787c25740a6d7b4885"
irb(main):002:0> ENV["SIDEKIQ_REDIS_URL"]
=> "redis://localhost:6379/7"

Now, when I look at the logs for sidekiq, I see nothing beyond the startup:

$ bin/sidekiq
2016-07-01T22:05:17.986Z 18262 TID-owbqr7xsc INFO: Booting Sidekiq 4.1.1 with redis options {:url=>"redis://localhost:6379/7"}


         m,
         `$b
    .ss,  $$:         .,d$
    `$$P,d$P'    .,md$P"'
     ,$$$$$bmmd$$$P^'
   .d$$$$$$$$$$P'
   $$^' `"^$$$'       ____  _     _      _    _
   $:     ,$$:       / ___|(_) __| | ___| | _(_) __ _
   `b     :$$        \___ \| |/ _` |/ _ \ |/ / |/ _` |
          $$:         ___) | | (_| |  __/   <| | (_| |
          $$         |____/|_|\__,_|\___|_|\_\_|\__, |
        .d$$                                       |_|

2016-07-01T22:05:18.802Z 18262 TID-owbqr7xsc INFO: Running in ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
2016-07-01T22:05:18.802Z 18262 TID-owbqr7xsc INFO: See LICENSE and the LGPL-3.0 for licensing details.
2016-07-01T22:05:18.802Z 18262 TID-owbqr7xsc INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
2016-07-01T22:05:18.806Z 18262 TID-owbqr7xsc DEBUG: Client Middleware:
2016-07-01T22:05:18.821Z 18262 TID-owbqr7xsc DEBUG: Server Middleware: Sidekiq::Middleware::Server::Logging, Sidekiq::Middleware::Server::RetryJobs, Sidekiq::Middleware::Server::ActiveRecord
2016-07-01T22:05:18.821Z 18262 TID-owbqr7xsc INFO: Starting processing, hit Ctrl-C to stop
2016-07-01T22:05:18.868Z 18262 TID-owbqr7xsc DEBUG: {:queues=>["default", "mailers"], :labels=>[], :concurrency=>5, :require=>".", :environment=>nil, :timeout=>8, :poll_interval_average=>nil, :average_scheduled_poll_interval=>15, :error_handlers=>[#<Sidekiq::ExceptionHandler::Logger:0x007fc3fb27d938>, #<Proc:0x007fc3fb70f578@/usr/local/opt/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/exception_notification-4.1.4/lib/exception_notification/sidekiq.rb:27>], :lifecycle_events=>{:startup=>[], :quiet=>[], :shutdown=>[]}, :dead_max_jobs=>10000, :dead_timeout_in_seconds=>15552000, :verbose=>true, :pidfile=>"tmp/pids/sidekiq.pid", :staging=>{:concurrency=>10}, :production=>{:concurrency=>20}, :config_file=>"config/sidekiq.yml", :strict=>true, :tag=>"fenix"}

So, it seems that the job is never making it into the queue to be processed. 

What am I doing wrong?

Will Green

unread,
Jul 2, 2016, 10:59:40 AM7/2/16
to Sidekiq
A couple notes:

1. The name of the config file is a typo. it is named sidekiq.yml
2. I have subsequently set the environment explicitly when starting sidekiq (bin/sidekiq -e development), but still no dice.
3. Here's the redis keys for that database:

$ redis-cli -n 7
127.0.0.1:6379[7]> KEYS *
1) "stat:failed:2016-07-02"
2) "9500075953A:24955:7db1a336c600"
3) "stat:processed:2016-07-02"
4) "stat:processed"
5) "stat:failed"
6) "stat:processed:2016-07-01"
7) "stat:failed:2016-07-01"
8) "processes"
127.0.0.1:6379[7]>

9500075953A is the hostname of my machine

Will Green

unread,
Jul 5, 2016, 8:12:33 AM7/5/16
to Sidekiq
I feel like an idiot. I had rspec-sidekiq in a group that included both development and test in my Gemfile. Moving it to a group that only has development cleared it right up.

Will Green

unread,
Jul 5, 2016, 8:21:10 AM7/5/16
to Sidekiq
I mean moving it to a group that only had test cleared it up.

group :test do
  gem 'factory_girl_rails', '~> 4.7'
  gem 'rspec-activemodel-mocks', '~> 1.0', '>= 1.0.3'
  gem 'rspec-rails', '~> 3.0'
  gem 'rspec-sidekiq'
  gem 'shoulda-matchers', '~> 3.1'
  gem 'simplecov', require: false
  gem 'simplecov-json', require: false
end
Reply all
Reply to author
Forward
0 new messages