rufus-scheduler 3.3.4 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.txt +24 -0
- data/CREDITS.txt +7 -0
- data/Makefile +4 -0
- data/README.md +8 -7
- data/lib/rufus/scheduler/job_array.rb +0 -24
- data/lib/rufus/scheduler/jobs.rb +25 -40
- data/lib/rufus/scheduler/locks.rb +0 -23
- data/lib/rufus/scheduler/util.rb +151 -240
- data/lib/rufus/scheduler.rb +52 -46
- data/rufus-scheduler.gemspec +9 -5
- metadata +23 -24
- data/TODO.txt +0 -151
- data/fail.txt +0 -2
- data/fail18.txt +0 -12
- data/lib/rufus/scheduler/cronline.rb +0 -523
- data/lib/rufus/scheduler/zotime.rb +0 -488
- data/n.txt +0 -38
- data/pics.txt +0 -15
- data/sofia.md +0 -89
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b8c6844d5f77112580ff29651a33fe2bc3b9545f
|
|
4
|
+
data.tar.gz: 329289b1d8a476270440672b4efd71d4d41e976d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8a7a056a68f73e62a54b44cbb40c3862e70b75cd92bfbe887ac39c8f72c7398798bb5062272d7d78b8aeeaf3083971276febfa36fb2e7e534b4cd9efb5b7e41a
|
|
7
|
+
data.tar.gz: a0e682b539d953cf706ee0d431dfd175994c67f8ddeeb61dc5e1d966bf5fd56e79b0c92d5f32e1abaf80fa1674a774d743cb4acc1b248125b55b000a98344d1a
|
data/CHANGELOG.txt
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
= rufus-scheduler CHANGELOG.txt
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
== rufus-scheduler - 3.5.0 released 2018-05-15
|
|
6
|
+
|
|
7
|
+
- Use fugit to parse durations
|
|
8
|
+
- Drop .parse_time_string and .parse_duration_string
|
|
9
|
+
- Use fugit to parse cronlines
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
== rufus-scheduler - 3.4.2 released 2017-05-24
|
|
13
|
+
|
|
14
|
+
(had yanked 3.4.1, going 3.4.2)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
== rufus-scheduler - 3.4.1 released 2017-05-24
|
|
18
|
+
|
|
19
|
+
- Let #schedule accept a CronLine instance, gh-247
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
== rufus-scheduler - 3.4.0 released 2017-03-23
|
|
23
|
+
|
|
24
|
+
- Stop supporting Ruby < 1.9
|
|
25
|
+
- Drop ZoTime for et-orbi's Etorbi::EoTime, gh-240
|
|
26
|
+
- Fix for ZooKeeper example, thanks to @djrodgerspryor, gh-238
|
|
27
|
+
|
|
28
|
+
|
|
5
29
|
== rufus-scheduler - 3.3.4 released 2017-02-16
|
|
6
30
|
|
|
7
31
|
- More detailed "cannot determine timezone from nil" message, gh-237
|
data/CREDITS.txt
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
== Contributors
|
|
6
6
|
|
|
7
|
+
- Wes McNamee (https://github.com/ghostsquad) - let #schedule accept a CronLine
|
|
8
|
+
- Joe Rafaniello (https://github.com/jrafanie) - Travis Ruby 2.4.1
|
|
9
|
+
- Benjamin Fleischer (https://github.com/bf4) - ZoTime#subtract
|
|
10
|
+
- Sam Rowe (https://github.com/riddley) - gh-240 timezone for Debian
|
|
11
|
+
- Daniel Rodgers-Pryor (https://github.com/djrodgerspryor) - gh-238 fix ZooKeeper example
|
|
7
12
|
- Cody Cutrer (https://github.com/ccutrer) - gh-232 is_a?(Fixnum) replacement
|
|
8
13
|
- Dominik Sander (https://github.com/dsander) - gh-225, gh-226
|
|
9
14
|
- Piavka (https://github.com/piavka) - Job#trigger_off_schedule, gh-214
|
|
@@ -53,6 +58,8 @@
|
|
|
53
58
|
|
|
54
59
|
== Feedback
|
|
55
60
|
|
|
61
|
+
- Gian - https://github.com/snmgian - cron vs :first clarification - gh-266
|
|
62
|
+
- Vito Laurenza - https://github.com/veetow - help debugging tz issues - gh-240
|
|
56
63
|
- Yoshimi Keiji - https://githuc.com/walf443 - v.3.3.3 mislabelling
|
|
57
64
|
- Alexander Deeb - https://github.com/adeeb1 - gh-230
|
|
58
65
|
- Sofia Bravo - http://stackoverflow.com/users/1123850/sofia-bravo - gh-231
|
data/Makefile
CHANGED
|
@@ -4,6 +4,10 @@ NAME = \
|
|
|
4
4
|
VERSION = \
|
|
5
5
|
$(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version")
|
|
6
6
|
|
|
7
|
+
count_lines:
|
|
8
|
+
find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
|
|
9
|
+
find spec -name "*_spec.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
|
|
10
|
+
cl: count_lines
|
|
7
11
|
|
|
8
12
|
gemspec_validate:
|
|
9
13
|
@echo "---"
|
data/README.md
CHANGED
|
@@ -103,7 +103,7 @@ I'll drive you right to the [tracks](#so-rails).
|
|
|
103
103
|
|
|
104
104
|
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.
|
|
105
105
|
|
|
106
|
-
"hello" and "thanks" are not swear words.
|
|
106
|
+
"hello", "please" and "thanks" are not swear words.
|
|
107
107
|
|
|
108
108
|
Go read [how to report bugs effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html), twice.
|
|
109
109
|
|
|
@@ -128,6 +128,7 @@ Yes, issues can be reported in [rufus-scheduler issues](https://github.com/jmett
|
|
|
128
128
|
* [Passenger in-depth spawn methods](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/)
|
|
129
129
|
* [Passenger in-depth spawn methods (smart spawning)](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#smart-spawning-hooks)
|
|
130
130
|
* [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)
|
|
131
|
+
* [The job triggers twice](https://github.com/jmettraux/rufus-scheduler#lockfile--mylockfiletxt)
|
|
131
132
|
* [I don't get any of this, I just want it to work in my Rails application](#so-rails)
|
|
132
133
|
* [I get "zotime.rb:41:in `initialize': cannot determine timezone from nil"](#i-get-zotimerb41in-initialize-cannot-determine-timezone-from-nil)
|
|
133
134
|
|
|
@@ -376,7 +377,7 @@ Since, by default, jobs are triggered in their own new thread, job instances mig
|
|
|
376
377
|
|
|
377
378
|
To prevent overlap, one can set :overlap => false. Such a job will not trigger if one of its instance is already running.
|
|
378
379
|
|
|
379
|
-
The `:overlap` option is considered
|
|
380
|
+
The `:overlap` option is considered after the `:mutex` option when the scheduler is reviewing jobs for triggering.
|
|
380
381
|
|
|
381
382
|
### :mutex => mutex_instance / mutex_name / array of mutexes
|
|
382
383
|
|
|
@@ -415,7 +416,7 @@ This option is for repeat jobs (cron / every) only.
|
|
|
415
416
|
It's used to specify the first time after which the repeat job should trigger for the first time.
|
|
416
417
|
|
|
417
418
|
In the case of an "every" job, this will be the first time (modulo the scheduler frequency) the job triggers.
|
|
418
|
-
For a "cron" job,
|
|
419
|
+
For a "cron" job as well, the :first will point to the first time the job has to trigger, the following trigger time are then determined by the cron string.
|
|
419
420
|
|
|
420
421
|
```ruby
|
|
421
422
|
scheduler.every '2d', :first_at => Time.now + 10 * 3600 do
|
|
@@ -439,7 +440,7 @@ job.first_at = Time.now + 10
|
|
|
439
440
|
job.first_at = Rufus::Scheduler.parse('2029-12-12')
|
|
440
441
|
```
|
|
441
442
|
|
|
442
|
-
The first argument (in all its flavours) accepts a :now or :immediately value. That schedules the first
|
|
443
|
+
The first argument (in all its flavours) accepts a :now or :immediately value. That schedules the first occurrence for immediate triggering. Consider:
|
|
443
444
|
|
|
444
445
|
```ruby
|
|
445
446
|
require 'rufus-scheduler'
|
|
@@ -847,7 +848,7 @@ Every jobs use a time duration between each start of their execution, while inte
|
|
|
847
848
|
|
|
848
849
|
### frequency
|
|
849
850
|
|
|
850
|
-
It returns the shortest interval of time between two potential
|
|
851
|
+
It returns the shortest interval of time between two potential occurrences of the job.
|
|
851
852
|
|
|
852
853
|
For instance:
|
|
853
854
|
```ruby
|
|
@@ -1282,7 +1283,7 @@ end
|
|
|
1282
1283
|
|
|
1283
1284
|
This uses a [zookeeper](http://zookeeper.apache.org/) to make sure only one scheduler in a group of distributed schedulers runs.
|
|
1284
1285
|
|
|
1285
|
-
The methods #lock and #unlock are
|
|
1286
|
+
The methods #lock and #unlock are overridden and #confirm_lock is provided,
|
|
1286
1287
|
to make sure that the lock is still valid.
|
|
1287
1288
|
|
|
1288
1289
|
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.
|
|
@@ -1449,7 +1450,7 @@ rufus-scheduler/lib/rufus/scheduler/zotime.rb:41:
|
|
|
1449
1450
|
...
|
|
1450
1451
|
```
|
|
1451
1452
|
|
|
1452
|
-
It may happen on Windows or on systems that poorly hints to Ruby on which timezone to use. It should be solved by setting
|
|
1453
|
+
It may happen on Windows or on systems that poorly hints to Ruby on which timezone to use. It should be solved by setting explicitly the `ENV['TZ']` before the scheduler instantiation:
|
|
1453
1454
|
```ruby
|
|
1454
1455
|
ENV['TZ'] = 'Asia/Shanghai'
|
|
1455
1456
|
scheduler = Rufus::Scheduler.new
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
|
-
# Copyright (c) 2006-2017, John Mettraux, jmettraux@gmail.com
|
|
3
|
-
#
|
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
# furnished to do so, subject to the following conditions:
|
|
10
|
-
#
|
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
|
12
|
-
# all copies or substantial portions of the Software.
|
|
13
|
-
#
|
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
# THE SOFTWARE.
|
|
21
|
-
#
|
|
22
|
-
# Made in Japan.
|
|
23
|
-
#++
|
|
24
|
-
|
|
25
1
|
|
|
26
2
|
module Rufus
|
|
27
3
|
|
data/lib/rufus/scheduler/jobs.rb
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
|
-
# Copyright (c) 2006-2017, John Mettraux, jmettraux@gmail.com
|
|
3
|
-
#
|
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
# furnished to do so, subject to the following conditions:
|
|
10
|
-
#
|
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
|
12
|
-
# all copies or substantial portions of the Software.
|
|
13
|
-
#
|
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
# THE SOFTWARE.
|
|
21
|
-
#
|
|
22
|
-
# Made in Japan.
|
|
23
|
-
#++
|
|
24
|
-
|
|
25
1
|
|
|
26
2
|
module Rufus
|
|
27
3
|
|
|
@@ -86,7 +62,7 @@ module Rufus
|
|
|
86
62
|
nil
|
|
87
63
|
end
|
|
88
64
|
|
|
89
|
-
@scheduled_at =
|
|
65
|
+
@scheduled_at = EoTime.now
|
|
90
66
|
@unscheduled_at = nil
|
|
91
67
|
@last_time = nil
|
|
92
68
|
|
|
@@ -132,14 +108,14 @@ module Rufus
|
|
|
132
108
|
# Done in collaboration with Piavka in
|
|
133
109
|
# https://github.com/jmettraux/rufus-scheduler/issues/214
|
|
134
110
|
#
|
|
135
|
-
def trigger_off_schedule(time=
|
|
111
|
+
def trigger_off_schedule(time=EoTime.now)
|
|
136
112
|
|
|
137
113
|
do_trigger(time)
|
|
138
114
|
end
|
|
139
115
|
|
|
140
116
|
def unschedule
|
|
141
117
|
|
|
142
|
-
@unscheduled_at =
|
|
118
|
+
@unscheduled_at = EoTime.now
|
|
143
119
|
end
|
|
144
120
|
|
|
145
121
|
def threads
|
|
@@ -199,7 +175,7 @@ module Rufus
|
|
|
199
175
|
#
|
|
200
176
|
def call(do_rescue=false)
|
|
201
177
|
|
|
202
|
-
do_call(
|
|
178
|
+
do_call(EoTime.now, do_rescue)
|
|
203
179
|
end
|
|
204
180
|
|
|
205
181
|
protected
|
|
@@ -266,7 +242,7 @@ module Rufus
|
|
|
266
242
|
|
|
267
243
|
def trigger_now(time)
|
|
268
244
|
|
|
269
|
-
t =
|
|
245
|
+
t = EoTime.now
|
|
270
246
|
# if there are mutexes, t might be really bigger than time
|
|
271
247
|
|
|
272
248
|
Thread.current[:rufus_scheduler_job] = self
|
|
@@ -280,7 +256,7 @@ module Rufus
|
|
|
280
256
|
ensure
|
|
281
257
|
|
|
282
258
|
@last_work_time =
|
|
283
|
-
|
|
259
|
+
EoTime.now - Thread.current[:rufus_scheduler_time]
|
|
284
260
|
@mean_work_time =
|
|
285
261
|
((@count - 1) * @mean_work_time + @last_work_time) / @count
|
|
286
262
|
|
|
@@ -440,12 +416,13 @@ module Rufus
|
|
|
440
416
|
|
|
441
417
|
return (@first_at = nil) if first == nil
|
|
442
418
|
|
|
443
|
-
n0 =
|
|
419
|
+
n0 = EoTime.now
|
|
444
420
|
n1 = n0 + 0.003
|
|
445
421
|
|
|
446
422
|
first = n0 if first == :now || first == :immediately || first == 0
|
|
423
|
+
fdur = Rufus::Scheduler.parse_duration(first, no_error: true)
|
|
447
424
|
|
|
448
|
-
@first_at =
|
|
425
|
+
@first_at = (fdur && (EoTime.now + fdur)) || EoTime.make(first)
|
|
449
426
|
@first_at = n1 if @first_at >= n0 && @first_at < n1
|
|
450
427
|
|
|
451
428
|
fail ArgumentError.new(
|
|
@@ -458,13 +435,18 @@ module Rufus
|
|
|
458
435
|
|
|
459
436
|
def last_at=(last)
|
|
460
437
|
|
|
461
|
-
|
|
462
|
-
|
|
438
|
+
@last_at =
|
|
439
|
+
if last
|
|
440
|
+
ldur = Rufus::Scheduler.parse_duration(last, no_error: true)
|
|
441
|
+
(ldur && (EoTime.now + ldur)) || EoTime.make(last)
|
|
442
|
+
else
|
|
443
|
+
nil
|
|
444
|
+
end
|
|
463
445
|
|
|
464
446
|
fail ArgumentError.new(
|
|
465
447
|
"cannot set last[_at|_in] in the past: " +
|
|
466
448
|
"#{last.inspect} -> #{@last_at.inspect}"
|
|
467
|
-
) if last && @last_at <
|
|
449
|
+
) if last && @last_at < EoTime.now
|
|
468
450
|
|
|
469
451
|
@last_at
|
|
470
452
|
end
|
|
@@ -485,7 +467,7 @@ module Rufus
|
|
|
485
467
|
|
|
486
468
|
def pause
|
|
487
469
|
|
|
488
|
-
@paused_at =
|
|
470
|
+
@paused_at = EoTime.now
|
|
489
471
|
end
|
|
490
472
|
|
|
491
473
|
def resume
|
|
@@ -564,7 +546,7 @@ module Rufus
|
|
|
564
546
|
|
|
565
547
|
return if is_post
|
|
566
548
|
|
|
567
|
-
n =
|
|
549
|
+
n = EoTime.now
|
|
568
550
|
|
|
569
551
|
@next_time =
|
|
570
552
|
if @first_at && (trigger_time == nil || @first_at > n)
|
|
@@ -604,10 +586,10 @@ module Rufus
|
|
|
604
586
|
|
|
605
587
|
@next_time =
|
|
606
588
|
if is_post
|
|
607
|
-
|
|
589
|
+
EoTime.now + @interval
|
|
608
590
|
elsif trigger_time.nil?
|
|
609
591
|
if @first_at == nil || @first_at < Time.now
|
|
610
|
-
|
|
592
|
+
EoTime.now + @interval
|
|
611
593
|
else
|
|
612
594
|
@first_at
|
|
613
595
|
end
|
|
@@ -624,11 +606,14 @@ module Rufus
|
|
|
624
606
|
|
|
625
607
|
class CronJob < RepeatJob
|
|
626
608
|
|
|
609
|
+
attr_reader :cron_line
|
|
610
|
+
|
|
627
611
|
def initialize(scheduler, cronline, opts, block)
|
|
628
612
|
|
|
629
613
|
super(scheduler, cronline, opts, block)
|
|
630
614
|
|
|
631
|
-
@cron_line = opts[:_t] ||
|
|
615
|
+
@cron_line = opts[:_t] || ::Fugit::Cron.parse(cronline)
|
|
616
|
+
|
|
632
617
|
set_next_time(nil)
|
|
633
618
|
end
|
|
634
619
|
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
#--
|
|
2
|
-
# Copyright (c) 2006-2017, John Mettraux, jmettraux@gmail.com
|
|
3
|
-
#
|
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
# furnished to do so, subject to the following conditions:
|
|
10
|
-
#
|
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
|
12
|
-
# all copies or substantial portions of the Software.
|
|
13
|
-
#
|
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
-
# THE SOFTWARE.
|
|
21
|
-
#
|
|
22
|
-
# Made in Japan.
|
|
23
|
-
#++
|
|
24
1
|
|
|
25
2
|
require 'fileutils'
|
|
26
3
|
|