I am trying to setup a Sidekiq scheduler to run recurring jobs.
I can get the Sidekiq job to run fine in Rails console, or Rails app. I can get Whenever to trigger command. However, I CANNOT get Whenever to trigger Sidekiq job.
I replicated my work in different machines, and in some machine, I get it to work. In most other machine, it is not working.
Here is my setup:
# app/workers/create_random_product.rb
class CreateRandomProduct
include Sidekiq::Worker
def perform
new_product = Product.new
new_product.name = "Product #{Time.now}"
new_product.price = 5.5
new_product.save
end
end
# config/schedule.rb
every 1.minute do
runner "CreateRandomProduct.perform_async"
command "echo 'hello' >> /home/vagrant/output.txt"
end
As you can see in the schedule.rb, I can get the second command to run because I can see the output updated, but the first runner command does not seem to do anything. Sidekiq dashboard does not show any activity either.
Running "whenever" returns these cron jobs:
* * * * * /bin/bash -l -c 'cd /home/vagrant/sidekiqdemo && bin/rails runner -e production '\''CreateRandomProduct.perform_async'\'''
* * * * * /bin/bash -l -c 'echo '\''hello'\'' >> /home/vagrant/output.txt'
I ran the first command manually and it DOES trigger the Sidekiq job.
I did run the "whenever -i" command to update the crontab file. I check the crontab log, and I can see that it tried to trigger the Sidekiq job:
Oct 16 16:15:01 vagrant-ubuntu-trusty-64 CRON[13062]: (vagrant) CMD (/bin/bash -l -c 'cd /home/vagrant/sidekiqdemo && bin/rails runner -e production '\''CreateRandomProduct.perform_async'\''')
Oct 16 16:15:01 vagrant-ubuntu-trusty-64 CRON[13063]: (vagrant) CMD (/bin/bash -l -c 'echo '\''hello'\'' >> /home/vagrant/output.txt')
Is there anything that I am missing?