javan / whenever

Cron jobs in Ruby
MIT License
8.84k stars 726 forks source link

5.2.2 Jobs Not Running with job_type :runner #769

Open RIttera13 opened 5 years ago

RIttera13 commented 5 years ago

I had an issue after upgrading to 5.2.2 when jobs where not running. Jobs were added to crontab correctly and looked correct. I compared it to the crontab that worked before and it was the same. The issue was that the method to run the job was no longer working. I used a new job_type to use new commands and resolve the issue. The problem is that && bundle exec bin/rails needed to drop the "bin" and just read && bundle exec rails. I'm not sure if anyone else has had or can recreate the issue.

Just to confirm, the only changes made to my environment when this occurred was upgrading from Rails 5.0.1 to Rails 5.2.2.

Doesn't Work: Default - job_type :runner, "cd :path && bin/rails runner -e :environment ':task' :output"

Creates this cronjob - /bin/bash -l -c 'cd /var/deploy/MyApp/web_head/releases/20190201171815 && bundle exec bin/rails runner -e staging '\'MyJob.perform_now'\'''

Working Version: My Custom job_type - job_type :new_runner, "cd :path && bundle exec rails runner -e :environment ':task' :output"

Creates this cronjob - /bin/bash -l -c 'cd /var/deploy/MyApp/web_head/releases/20190201194724 && bundle exec rails runner -e staging '\''MyJob.perform_now'\'''

My environment is Ubuntu 16.04 self hosted but managed through Cloud66.

And thank you to the creators/maintainers of this awesome gem. Also, the ability to create a custom job_type made this issue very minor, so thank you for that as well.

igorkasyanchuk commented 5 years ago

I've got a similar issue that tasks are not executed, so I've added a logger and noticed this issue:

bundler: failed to load command: bin/rails (bin/rails) LoadError: cannot load such file -- bootsnap/setup /home/deploy/applications/platforma/releases/20190419062535/config/boot.rb:6:in require' /home/deploy/applications/platforma/releases/20190419062535/config/boot.rb:6:in<top (required)>' bin/rails:3:in require_relative' bin/rails:3:in<top (required)>'

because I've removed this gem from prod env. Check you logs set :output, "/home/deploy/applications/platforma/current/log/crontab.log"

maybe you have another issue.

ishields commented 3 years ago

@RIttera13 did you ever find a solution for this? I'm seeing a similar issue with Rails 6.1 and ruby 3.0.0

KevinTriplett commented 2 years ago

I had the same issue. My workaround was to create a rake task that simply calls my class method and create a cron job that runs the rake task. I got the added benefit of gaining a rake task I can manually run.