README.md in rufus-scheduler-3.5.2 vs README.md in rufus-scheduler-3.6.0
- old
+ new
@@ -1,10 +1,11 @@
# rufus-scheduler
-[![Build Status](https://secure.travis-ci.org/jmettraux/rufus-scheduler.svg)](http://travis-ci.org/jmettraux/rufus-scheduler)
-[![Gem Version](https://badge.fury.io/rb/rufus-scheduler.svg)](http://badge.fury.io/rb/rufus-scheduler)
+[![Build Status](https://secure.travis-ci.org/jmettraux/rufus-scheduler.svg)](https://travis-ci.org/jmettraux/rufus-scheduler)
+[![Gem Version](https://badge.fury.io/rb/rufus-scheduler.svg)](https://badge.fury.io/rb/rufus-scheduler)
+[![Join the chat at https://gitter.im/floraison/fugit](https://badges.gitter.im/floraison/fugit.svg)](https://gitter.im/floraison/fugit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Job scheduler for Ruby (at, cron, in and every jobs).
It uses threads.
@@ -56,10 +57,12 @@
end
# ...
```
+Rufus-scheduler uses [fugit](https://github.com/floraison/fugit) for parsing time strings, [et-orbi](https://github.com/floraison/et-orbi) for pairing time and [tzinfo](https://github.com/tzinfo/tzinfo) timezones.
+
## non-features
Rufus-scheduler (out of the box) is an in-process, in-memory scheduler. It uses threads.
It does not persist your schedules. When the process is gone and the scheduler instance with it, the schedules are gone.
@@ -70,11 +73,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/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
+* [PerfectSched](https://github.com/treasure-data/perfectsched) - highly available distributed cron built on [Sequel](https://sequel.jeremyevans.net) and more
(please note: rufus-scheduler is not a cron replacement)
## note about the 3.0 line
@@ -87,11 +90,11 @@
## I don't know what this Ruby thing is, where are my Rails?
I'll drive you right to the [tracks](#so-rails).
-## Notable changes:
+## 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 with Ruby's ```sleep(100)```
* The scheduler isn't catching the whole of Exception anymore, only StandardError
* 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)
@@ -106,30 +109,30 @@
So you need help. People can help you, but first help them help you, and don't waste their time. Provide a complete description of the issue. If it works on A but not on B and others have to ask you: "so what is different between A and B" you are wasting everyone's time.
"hello", "please" and "thanks" are not swear words.
-Go read [how to report bugs effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html), twice.
+Go read [how to report bugs effectively](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html), twice.
Update: [help_help.md](https://gist.github.com/jmettraux/310fed75f568fd731814) might help help you.
-### on IRC
+### on Gitter
-I sometimes haunt #ruote on freenode.net. The channel is not dedicated to rufus-scheduler, so if you ask a question, first mention it's about rufus-scheduler.
+You can find help via chat over at [https://gitter.im/floraison/fugit](https://gitter.im/floraison/fugit). It's [fugit](https://github.com/floraison/fugit), [et-orbi](https://github.com/floraison/et-orbi), and rufus-scheduler combined chat room.
-Please note that I prefer helping over Stack Overflow because it's more searchable than the ruote IRC archive.
+Please be courteous.
### issues
-Yes, issues can be reported in [rufus-scheduler issues](https://github.com/jmettraux/rufus-scheduler/issues), I'd actually prefer bugs in there. If there is nothing wrong with rufus-scheduler, a [Stack Overflow question](http://stackoverflow.com/questions/ask?tags=rufus-scheduler+ruby) is better.
+Yes, issues can be reported in [rufus-scheduler issues](https://github.com/jmettraux/rufus-scheduler/issues), I'd actually prefer bugs in there. If there is nothing wrong with rufus-scheduler, a [Stack Overflow question](https://stackoverflow.com/questions/ask?tags=rufus-scheduler+ruby) is better.
### faq
-* [It doesn't work...](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html)
-* [I want a refund](http://blog.nodejitsu.com/getting-refunds-on-open-source-projects)
-* [Passenger and rufus-scheduler](http://stackoverflow.com/questions/18108719/debugging-rufus-scheduler/18156180#18156180)
-* [Passenger and rufus-scheduler (2)](http://stackoverflow.com/questions/21861387/rufus-cron-job-not-working-in-apache-passenger#answer-21868555)
+* [It doesn't work...](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html)
+* [I want a refund](https://blog.nodejitsu.com/getting-refunds-on-open-source-projects)
+* [Passenger and rufus-scheduler](https://stackoverflow.com/questions/18108719/debugging-rufus-scheduler/18156180#18156180)
+* [Passenger and rufus-scheduler (2)](https://stackoverflow.com/questions/21861387/rufus-cron-job-not-working-in-apache-passenger#answer-21868555)
* [Passenger in-depth spawn methods](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/)
* [Passenger in-depth spawn methods (smart spawning)](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#smart-spawning-hooks)
* [The scheduler comes up when running the Rails console or a Rake task](https://github.com/jmettraux/rufus-scheduler#avoid-scheduling-when-running-the-ruby-on-rails-console)
* [The job triggers twice](https://github.com/jmettraux/rufus-scheduler#lockfile--mylockfiletxt)
* [I don't get any of this, I just want it to work in my Rails application](#so-rails)
@@ -685,10 +688,16 @@
The job keeps track of how long its work was in the `last_work_time` attribute. For a one time job (in, at) it's probably not very useful.
The attribute `mean_work_time` contains a computed mean work time. It's recomputed after every run (if it's a repeat job).
+### next_times(n)
+
+Returns an array of `EtOrbi::EoTime` instances (Time instances with a designated time zone), listing the `n` next occurrences for this job.
+
+Please note that for "interval" jobs, a mean work time is computed each time and it's used by this `#next_times(n)` method to approximate the next times beyond the immediate next time.
+
### unschedule
Unschedule the job, preventing it from firing again and removing it from the schedule. This doesn't prevent a running thread for this job to run until its end.
### threads
@@ -1229,11 +1238,11 @@
## Rufus::Scheduler.singleton
Do not want to store a reference to your rufus-scheduler instance?
-Then ```Rufus::Scheduler.singleton``` can help, it returns a singleon instance of the scheduler, initialized the first time this class method is called.
+Then ```Rufus::Scheduler.singleton``` can help, it returns a singleton instance of the scheduler, initialized the first time this class method is called.
```ruby
Rufus::Scheduler.singleton.every '10s' { puts "hello, world!" }
```
@@ -1288,11 +1297,11 @@
false
end
end
```
-This uses a [zookeeper](http://zookeeper.apache.org/) to make sure only one scheduler in a group of distributed schedulers runs.
+This uses a [zookeeper](https://zookeeper.apache.org/) to make sure only one scheduler in a group of distributed schedulers runs.
The methods #lock and #unlock are overridden and #confirm_lock is provided,
to make sure that the lock is still valid.
The #confirm_lock method is called right before a job triggers (if it is provided). The more generic callback #on_pre_trigger is called right after #confirm_lock.
@@ -1312,10 +1321,12 @@
Warning: you may think you're heading towards "high availability" by using a trigger lock and having lots of schedulers at hand. It may be so if you limit yourself to scheduling the same set of jobs at scheduler startup. But if you add schedules at runtime, they stay local to their scheduler. There is no magic that propagates the jobs to all the schedulers in your pack.
## parsing cronlines and time strings
+(Please note that [fugit](https://github.com/floraison/fugit) does the heavy-lifting parsing work for rufus-scheduler).
+
Rufus::Scheduler provides a class method ```.parse``` to parse time durations and cron strings. It's what it's using when receiving schedules. One can use it directly (no need to instantiate a Scheduler).
```ruby
require 'rufus-scheduler'
@@ -1548,37 +1559,33 @@
*Warning*: this works well with single-process Ruby servers like Webrick and Thin. Using rufus-scheduler with Passenger or Unicorn requires a bit more knowledge and tuning, gently provided by a bit of googling and reading, see [Faq](#faq) above.
### avoid scheduling when running the Ruby on Rails console
-(Written in reply to https://github.com/jmettraux/rufus-scheduler/issues/186 )
+(Written in reply to [gh-186](https://github.com/jmettraux/rufus-scheduler/issues/186))
-If you don't want rufus-scheduler to kick in when running the Ruby on Rails console or invoking a rake task, you can wrap your initializer in a conditional:
+If you don't want rufus-scheduler to trigger anything while running the Ruby on Rails console, running for tests/specs, or running from a Rake task, you can insert a conditional return statement before jobs are added to the scheduler instance:
```ruby
#
# config/initializers/scheduler.rb
require 'rufus-scheduler'
s = Rufus::Scheduler.singleton
+return if defined?(Rails::Console) || Rails.env.test? || File.split($0).last == 'rake'
-unless defined?(Rails::Console) || File.split($0).last == 'rake'
+# do not schedule when Rails is run from its console, for a test/spec, or
+# from a Rake task
- # only schedule when not running from the Ruby on Rails console
- # or from a rake task
-
- s.every '1m' do
-
- Rails.logger.info "hello, it's #{Time.now}"
- Rails.logger.flush
- end
+s.every '1m' do
+ Rails.logger.info "hello, it's #{Time.now}"
+ Rails.logger.flush
end
```
-It should work for Ruby on Rails 3 and 4.
### rails server -d
(Written in reply to https://github.com/jmettraux/rufus-scheduler/issues/165 )
@@ -1586,11 +1593,11 @@
I avoid running `-d` in development mode and bother about daemonizing only for production deployment.
These are two well crafted articles on process daemonization, please read them:
-* http://www.mikeperham.com/2014/09/22/dont-daemonize-your-daemons/
-* http://www.mikeperham.com/2014/07/07/use-runit/
+* https://www.mikeperham.com/2014/09/22/dont-daemonize-your-daemons/
+* https://www.mikeperham.com/2014/07/07/use-runit/
If, anyway, you need something like `rails server -d`, why not try `bundle exec unicorn -D` instead? In my (limited) experience, it worked out of the box (well, had to add `gem 'unicorn'` to `Gemfile` first).
## support