2

So I'm using Rails and I have a few Sidekiq workers, but none are enabled. I'm using the sidekiq-cron gem, which requires you to put files in app/workers/, configure a sidekiq scheduler in config/sidekiq_schedule.yml, and also add a few lines in config/initializers/sidekiq.rb. However, I've commented everything out from sidekiq_schedule.yml and also commented the following lines out from sidekiq.rb:

# Sidekiq scheduler.
# schedule_file = 'config/sidekiq_schedule.yml'

# if File.exists?(schedule_file) && Sidekiq.server?
#   Sidekiq::Cron::Job.load_from_hash! YAML.load_file(schedule_file)
# end

However, if I launch Sidekiq, every minute (which is the old schedule), I see this in the prompt:

2018-01-19T02:54:04.156Z 22197 TID-ovsidcme8 ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper JID-8609429b89db2a91793509ea INFO: start
2018-01-19T02:54:04.164Z 22197 TID-ovsidcme8 ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper JID-8609429b89db2a91793509ea INFO: fail: 0.008 sec

and it fails because it's trying to launch code a job that's not supposed to be launching.

I've went to the rails console prompt (rails -c) and tried to find the job, but nothing's in there:

irb(main):001:0> Sidekiq::Cron::Job.all
=> []

so I'm not quite sure why it's constantly trying to launch a job. If I go to the rails interface on my application, I don't see anything in the queue, nothing being processed, busy, retries, enqueued, nothing.

Any suggestions would be greatly appreciated. I've been trying to hunt this down for like the last hour and have no success. I even removed ALL of the workers from the workers directory, and yet it's still trying to launch one of them.

Ajay Barot
  • 1,681
  • 1
  • 21
  • 37
LewlSauce
  • 5,326
  • 8
  • 44
  • 91
  • If you have `Procfile` remove this line `worker: bundle exec sidekiq -c 5 -v` – fool-dev Jan 19 '18 at 04:45
  • Where's that line? I don't see it in any of the files. – LewlSauce Jan 19 '18 at 04:52
  • How do you deploy your code? How do you restart sidekiq after a code change? Is it possible that the running process is an old process that hasn't been stopped properly (something like `ps ax | grep sidekiq` might help to analyze the age of the process)? – spickermann Jan 19 '18 at 06:17
  • I usually just execute "sidekiq" (without backgrounding) and ctrl -c to stop it. I usually kill the process if it starts to act funny, just to make sure it's properly closed, but it still continues to proceed jobs even after restarting. – LewlSauce Jan 19 '18 at 06:18

2 Answers2

1

Because you have already load jobs, I think that those jobs configuration are still in REDIS. Checking this assumption by opening a new terminal tab with redis-cli:

KEYS '*cron*'

If there are those keys on REDIS, clear them will fix your issue.

Robert
  • 504
  • 5
  • 27
Tai
  • 1,244
  • 9
  • 11
  • This did the trick for me. I had already checked my crontab and didn't see anything, but accessing the redis-cli interface showed me a lot more information and revealed the things I needed to get cleared. Thanks a lot! – LewlSauce Jan 20 '18 at 05:28
  • 1
    Yep, it doesn't create cron job. It simulates cron by creating job description in Redis and check for new job schedule every 10s. If it creates cron job, you may encounter cron duplication when running sidekiq on multiple instances. – Tai Jan 20 '18 at 07:27
-1

Since you mentioned a cron job in your title but not in the question, I'm assuming there's a cronjob running the background sidekiq task.

Try running crontab - l in Terminal to see all your cron jobs. If you see something like "* * * * *", that means there's a job that is running every minute.

Then, use crontab - r to clear your cron tab and delete all scheduled tasks.

a3y3
  • 1,025
  • 2
  • 10
  • 34