As we get an exception notification, when a cron job fails, we wish to have the full backtrace in this mail. A rake task doesn't output the full backtrace by default, so you need the --backtrace
option.
Trigger
You will find fail mails with a shortened backtrace
#[...]
Tasks: TOP => some_namespace:some_task
(See full trace by running task with --trace)
What rake wants from you
Running the rake task like rake some_namespace:some_task --backtrace
How this works with whenever
Define a own job_type and use it for rake tasks in schedule.rb
job_type :backtraced_rake, "cd :path && :environment_variable=:environment bundle exec rake :task --silent --backtrace :output"
every 15.minutes do
backtraced_rake 'users:send_notifications'
end
How this works with craken
As we use craken in old projects, here is how you fix it in the craken.rb
crontab << " cd #{DEPLOY_PATH} && #{RAKE_EXE} --silent --backtrace RAILS_ENV=#{RAKETAB_RAILS_ENV}"
Posted by Emanuel to makandra dev (2015-11-20 10:04)