AnkitG
AnkitG

Reputation: 6568

Sidekiq worker not getting triggered

I am using Sidekiq for my background jobs:

I have a worker app/workers/data_import_worker.rb

class DataImportWorker
 include Sidekiq::Worker
 sidekiq_options retry: false

  def perform(job_id,file_name)
    begin
    #Some logic in it .....
  end
 end

Called from a file lib/parse_excel.rb

  def parse_raw_data
      #job_id and #filename are defined bfr
      DataImportWorker.perform_async(job_id,filename)   
  end

As soon as i trigger it from my action the worker is not getting called.. Redis is running on localhost:6379

Any idea why this must be happening. The Environment is Linux.

Upvotes: 21

Views: 24493

Answers (9)

sandre89
sandre89

Reputation: 5918

Lost a good 15 min on this. To check if Sidekiq is correctly loading your config file (with the queues names), go to the web interface in the Busy tab and you'll find your Process ID and below it you'll find your queues.

In our case, we had misspelled mailer (the correct ActiveJob queue for Mailers is mailers, in plural).

Upvotes: 1

Antony
Antony

Reputation: 1764

I was calling perform_async(23) in a production console, however my sidekiq was started in staging mode.

After I started the Sidekiq in production mode, things have started working very well.

Upvotes: 0

basgys
basgys

Reputation: 4400

I had a similar problem where Sidekiq was running but when I called perform_async it didn't do anything except return true.

The problem was rspec-sidekiq was added to my ":development, :test" group. I fixed the problem by moving rspec-sidekiq to the ":test" group only.

Upvotes: 34

rlawrenz
rlawrenz

Reputation: 166

For me when doing a perform_later, it would enqueue but never remove from queue. I needed to add my queue name to the sidekiq.yml file

---
:concurrency: 25
:pidfile: ./tmp/pids/sidekiq.pid
:logfile: ./log/sidekiq.log
:queues:
  - default
  - my_queue

Upvotes: 1

ajahongir
ajahongir

Reputation: 479

is it realy run multiple workers on standalone sidekiq? for example I have 2 workers: ProccessWorker CallbackWorker

when I am runnigs sidekiq: bundle exec sidekiq -r ./workers/proccess_worker.rb -C ./config/sidekiq.yml

only one worker in same time.

Upvotes: 0

Ranjithkumar Ravi
Ranjithkumar Ravi

Reputation: 3492

Start sidekiq from the root directory of your Rails app. For example,

bundle exec sidekiq -e staging -C config/sidekiq.yml

Upvotes: 8

mecampbellsoup
mecampbellsoup

Reputation: 1521

My issue was simply having the worker file in the wrong path.

Needs to be in "project_root/app/worker/worker.rb", not "project_root/worker/worker.rb"

Check the file path!

Upvotes: 0

Henley Wing Chiu
Henley Wing Chiu

Reputation: 22535

You need to specify the name of the queue that worker is for.

Example: sidekiq_options retry: false, :queue => data_import_worker

data_import_worker can be any name you want to give it.

Then when you go to the web interface: yoursite.com/sidekiq, you'll be able to see the current workers for the queue "data_import_worker"

Upvotes: 1

alikewmk
alikewmk

Reputation: 145

I encounter the same problem, it turns out that the argument I've passed in the function perform_async is not appropriate, it seems that one should not pass any query result in perform_async, you must do all the query in the function perform.

Upvotes: 2

Related Questions