3
votes

So I just migrated to Rails 5.1.4 and I'm trying to make Active Job work, but the jobs are just stuck in the queue and never processed.

  • rails: 5.1.4
  • ruby: 2.4.3
  • sidekiq: 5.0.5
  • redis: 4.0.1

sidekiq.yml

---
:verbose: true
:concurrency: 5
:timeout: 60
development:
  :concurrency: 25
staging:
  :concurrency: 50
production:
  :concurrency: 5
:queues:
  - default
  - [high_priority, 2]

sidekiq.rb

Sidekiq.configure_server do |config|
  config.redis = {url: ENV['ACTIVE_JOB_URL'], network_timeout: 5}
end

Sidekiq.configure_client do |config|
  config.redis = {url: ENV['ACTIVE_JOB_URL'], network_timeout: 5}
end

Here the is how I perform the task from the rails console:

TestJob.perform_later

TestJob.rb content:

class TestJob < ApplicationJob
  queue_as :default

  def perform(*args)
    Rails.logger.debug "#{self.class.name}: I'm performing my job with arguments: #{args.inspect}"
  end
end

The jobs are just stuck in the queue and never processed:

enter image description here

1
First, stop your Sidekiq server. Then, from the command line, type redis-cli, then flushall, then exit. This will destroy everything that's in the redis database and let you start over. Then restart Sidekiq. - moveson

1 Answers

2
votes

Have you started the worker, eg in development it might be:

bundle exec sidekiq

If in production Heroku should do this for you, if you have configured your Procfile, eg:

web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq

You can also use your Procfile in development with foreman, eg:

foreman start -f Procfile