Sidekiq worker not getting triggered
Asked Answered
H

9

21

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.

Hyperbolize answered 10/10, 2012 at 9:34 Comment(5)
Is sidekiq running? What does it say in the log? Did you check redis, is the job added to queue:default ?Swellhead
@Roman: Thanks for reply! yes sidekiq and redis both are running .. the job is also not getting added to default queue... but when i trigger job from console it worksHyperbolize
Perhaps you've different databases or namespaces when running in development and production. Or a different queue is set up.Swellhead
@Roman: didn't get you.. can u elaborate please?Hyperbolize
I'm referring to this: github.com/mperham/sidekiq/wiki/Advanced-OptionsSwellhead
M
34

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.

Milliliter answered 12/6, 2013 at 12:38 Comment(5)
This was the similar problem in my caseHyperbolize
I had the same exact issue. I had to rebuild my bundle as well: bundle install --without testRigney
I added a link to this answer at github.com/mperham/sidekiq/wiki/… for future referenceInconsiderable
thank you for the providing your answer, I was about to throw my machine ou the window.Ginelle
also see github.com/philostler/rspec-sidekiq for a call out of this potential issueBacolod
P
8

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

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

Paperboard answered 11/3, 2014 at 12:43 Comment(0)
C
2

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.

Coltin answered 10/1, 2013 at 8:48 Comment(0)
V
1

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"

Vibrio answered 12/1, 2013 at 2:5 Comment(0)
K
1

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
Kleenex answered 11/11, 2016 at 23:12 Comment(0)
L
1

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).

Lodmilla answered 8/8, 2017 at 19:50 Comment(0)
D
0

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!

Dewain answered 19/11, 2013 at 14:13 Comment(0)
B
0

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.

Babble answered 21/10, 2014 at 12:21 Comment(0)
E
0

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.

Entero answered 26/5, 2017 at 19:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.