README.md in rufus-scheduler-3.3.1 vs README.md in rufus-scheduler-3.3.2
- old
+ new
@@ -6,11 +6,11 @@
Job scheduler for Ruby (at, cron, in and every jobs).
It uses threads.
-**Note**: maybe are you looking for the [README of rufus-scheduler 2.x](https://github.com/jmettraux/rufus-scheduler/blob/two/README.rdoc)?
+**Note**: maybe are you looking for the [README of rufus-scheduler 2.x](https://github.com/jmettraux/rufus-scheduler/blob/two/README.rdoc)? (especially if you're using [Dashing](https://github.com/Shopify/dashing) which is [stuck](https://github.com/Shopify/dashing/blob/master/dashing.gemspec) on rufus-scheduler 2.0.24)
Quickstart:
```ruby
# quickstart.rb
@@ -65,11 +65,11 @@
## related and similar gems
* [Whenever](https://github.com/javan/whenever) - let cron call back your Ruby code, trusted and reliable cron drives your schedule
-* [Clockwork](https://github.com/tomykaira/clockwork) - rufus-scheduler inspired gem
+* [Clockwork](https://github.com/Rykian/clockwork) - rufus-scheduler inspired gem
* [Crono](https://github.com/plashchynski/crono) - an in-Rails cron scheduler
* [PerfectSched](https://github.com/treasure-data/perfectsched) - highly available distributed cron built on [Sequel](http://sequel.jeremyevans.net) and more
(please note: rufus-scheduler is not a cron replacement)
@@ -89,11 +89,11 @@
## Notable changes:
* As said, no more EventMachine-based scheduler
* ```scheduler.every('100') {``` will schedule every 100 seconds (previously, it would have been 0.1s). This aligns rufus-scheduler on Ruby's ```sleep(100)```
* The scheduler isn't catching the whole of Exception anymore, only StandardError
-* The error_handler is #on_error (instead of #on_exception), by default it now prints the details of the error to $stderr (used to be $stdout)
+* The error_handler is [#on_error](#rufusscheduleron_errorjob-error) (instead of #on_exception), by default it now prints the details of the error to $stderr (used to be $stdout)
* Rufus::Scheduler::TimeOutError renamed to Rufus::Scheduler::TimeoutError
* Introduction of "interval" jobs. Whereas "every" jobs are like "every 10 minutes, do this", interval jobs are like "do that, then wait for 10 minutes, then do that again, and so on"
* Introduction of a :lockfile => true/filename mechanism to prevent multiple schedulers from executing
* "discard_past" is on by default. If the scheduler (its host) sleeps for 1 hour and a ```every '10m'``` job is on, it will trigger once at wakeup, not 6 times (discard_past was false by default in rufus-scheduler 2.x). No intention to re-introduce ```:discard_past => false``` in 3.0 for now.
* Introduction of Scheduler #on_pre_trigger and #on_post_trigger callback points
@@ -780,11 +780,11 @@
end
job.call
```
-Warning: the Scheduler#on_error handler is not involved. Error handling is the responsibility of the caller.
+Warning: the Scheduler[#on_error](#rufusscheduleron_errorjob-error) handler is not involved. Error handling is the responsibility of the caller.
If the call has to be rescued by the error handler of the scheduler, ```call(true)``` might help:
```ruby
require 'rufus-scheduler'
@@ -1059,9 +1059,23 @@
```ruby
def scheduler.on_error(job, error)
Logger.warn("intercepted error in #{job.id}: #{error.message}")
+end
+```
+
+On Rails, the `on_error` method redefinition might look like:
+```ruby
+def scheduler.on_error(job, error)
+
+ Rails.logger.error(
+ "err#{error.object_id} rufus-scheduler intercepted #{error.inspect}" +
+ " in job #{job.inspect}")
+ error.backtrace.each_with_index do |line, i|
+ Rails.logger.error(
+ "err#{error.object_id} #{i}: #{line}")
+ end
end
```
## Rufus::Scheduler #on_pre_trigger and #on_post_trigger callbacks