Sidekiq worker not getting triggered

2019-02-12 01:08发布

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.

9条回答
叛逆
2楼-- · 2019-02-12 01:24

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

查看更多
小情绪 Triste *
3楼-- · 2019-02-12 01:25

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
查看更多
\"骚年 ilove
4楼-- · 2019-02-12 01:26

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.

查看更多
神经病院院长
5楼-- · 2019-02-12 01:27

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.

查看更多
Explosion°爆炸
6楼-- · 2019-02-12 01:31

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!

查看更多
Evening l夕情丶
7楼-- · 2019-02-12 01:32

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.

查看更多
登录 后发表回答