sidekiq-scheduler 4.0.0 → 6.0.1
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.md +113 -11
- data/README.md +146 -68
- data/lib/sidekiq-scheduler/config.rb +91 -0
- data/lib/sidekiq-scheduler/extensions/web.rb +18 -10
- data/lib/sidekiq-scheduler/job_presenter.rb +1 -1
- data/lib/sidekiq-scheduler/manager.rb +26 -30
- data/lib/sidekiq-scheduler/redis_manager.rb +49 -20
- data/lib/sidekiq-scheduler/rufus_utils.rb +2 -2
- data/lib/sidekiq-scheduler/schedule.rb +2 -4
- data/lib/sidekiq-scheduler/scheduler.rb +57 -22
- data/lib/sidekiq-scheduler/sidekiq_adapter.rb +41 -0
- data/lib/sidekiq-scheduler/utils.rb +47 -7
- data/lib/sidekiq-scheduler/version.rb +1 -1
- data/lib/sidekiq-scheduler/web.rb +29 -4
- data/lib/sidekiq-scheduler.rb +7 -5
- data/web/assets/recurring_jobs/stylesheets-scheduler/recurring_jobs.css +81 -0
- data/web/assets/{stylesheets/recurring_jobs.css → recurring_jobs/stylesheets-scheduler/recurring_jobs_73.css} +18 -0
- data/web/locales/cs.yml +1 -0
- data/web/locales/de.yml +3 -0
- data/web/locales/en.yml +3 -0
- data/web/locales/es.yml +1 -0
- data/web/locales/fr.yml +5 -1
- data/web/locales/gd.yml +17 -0
- data/web/locales/it.yml +1 -0
- data/web/locales/ja.yml +1 -0
- data/web/locales/nl.yml +1 -0
- data/web/locales/pl.yml +1 -0
- data/web/locales/pt-BR.yml +2 -1
- data/web/locales/ru.yml +3 -0
- data/web/locales/sv.yml +1 -0
- data/web/locales/zh-cn.yml +1 -0
- data/web/views/recurring_jobs.erb +45 -57
- data/web/views/sidekiq73/recurring_jobs.erb +61 -0
- metadata +24 -71
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c844d2bcdc0efadeadb566cc2c9d47e91d4378b81aa64da7cb028ff0e4ffe23
|
|
4
|
+
data.tar.gz: 4b63963a350ef8e04e34954848bf904b3e0536bb1e2d176e56740f910fa96f6b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fed9af4e1cdc54eaaf5a793e33dacb2b586b13d2a4c6715d598e71bedcf24a97bce811b855b878cde9b344b2124cc653d0cb42577efc7d6e61fd33b5a066399
|
|
7
|
+
data.tar.gz: 41c582e2e546bd665c94364a37d66fc503e83fc4a002dd7f84f3115b6e65f1bfabd59d4f1b28aa73cf6a9cafba5492923d8996bb28ce08734350bc48e3c283bf
|
data/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,118 @@
|
|
|
1
|
+
# 6.0.1
|
|
2
|
+
- [**FIX**] Fix issue with Sidekiq v7.3.0-v7.3.6 [#503](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/503)
|
|
3
|
+
|
|
4
|
+
# 6.0.0
|
|
5
|
+
- Check the changelog for beta1 and beta2 of this version.
|
|
6
|
+
|
|
7
|
+
# 6.0.0.beta2
|
|
8
|
+
- [**FIX**/**BREAKING CHANGE**] Don't clear "schedule" key on boot in `dynamic` schedule mode [#467](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/467)
|
|
9
|
+
- If you use sidekiq-scheduler with the `dynamic` mode, be aware that the schedule key won't be cleared on boot anymore (so maybe patches handling that in your codebase might have to be removed)
|
|
10
|
+
- [**FIX**] SidekiqScheduler::Manager enormous inspect output [17f9c7f](https://github.com/sidekiq-scheduler/sidekiq-scheduler/commit/17f9c7ffc7f7db79a1cb047bed985f2bdf12ac92) / [#462](https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/462).
|
|
11
|
+
- [**FIX/ENHANCEMENT**] Remove checks that would raise an error if any of the following options was not under the `scheduler` key (`enabled`, `dynamic`, `dynamic_every`, `schedule`, `listened_queues_only`, `rufus_scheduler_options`). [1e64958](https://github.com/sidekiq-scheduler/sidekiq-scheduler/commit/1e6495838aaee91cbf53fbd57c3749f0ed35dc28) / [#469](https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/469)
|
|
12
|
+
- This was needed for those migrating from v4 to v5, but isn't anymore.
|
|
13
|
+
|
|
14
|
+
# 6.0.0.beta1
|
|
15
|
+
- [**ENHANCEMENT**] Adds compatibility with Sidekiq 8 [#497](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/497)
|
|
16
|
+
- [**BREAKING CHANGE**] Drop support for Sidekiq 7.2 and earlier [#497](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/498)
|
|
17
|
+
|
|
18
|
+
# 5.0.6
|
|
19
|
+
- [**FIX**] Fix typo in `config#to_hash` method [#479](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/479)
|
|
20
|
+
- [**FIX**] Correctly clear scheduled jobs with Scheduler#clear_schedule! [#485](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/485)
|
|
21
|
+
- [**FIX**] Fix scheduling of aperiodic cron jobs [#487](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/487) (see [#484](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/484) for more details as well)
|
|
22
|
+
|
|
23
|
+
# 5.0.5
|
|
24
|
+
- [**FIX**] Use correct folder structure for assets [#476](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/476)
|
|
25
|
+
|
|
26
|
+
# 5.0.4
|
|
27
|
+
- [**FIX**] Ensure rufus-scheduler has a default rufus_scheduler_options value [#434](https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/426)
|
|
28
|
+
- [**ENHANCEMENT**] Remove code related to sidekiq < 6 [#443](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/443)
|
|
29
|
+
- [**ENHANCEMENT**] Change cache-control to `private` [#446](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/446)
|
|
30
|
+
- [**ENHANCEMENT**] Increase compatibility range with tilt dependency [#458](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/458)
|
|
31
|
+
- [**ENHANCEMENT**] Ensure we support Ruby 3.3 [#461](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/461)
|
|
32
|
+
- [**ENHANCEMENT**] Use Redis MULTI command (https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/464)
|
|
33
|
+
- [**ENHANCEMENT**] Don't attempt to set jon next_time when job is nil [#466](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/466)
|
|
34
|
+
- [**ENHANCEMENT**] Improvements to prevent jobs been enqueued multiple times due to a delay in job execution [#463](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/463)
|
|
35
|
+
- [**FIX**] Prevent stack level too deep error by implementing `to_hash` method [#470](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/470)
|
|
36
|
+
- [**ENHANCEMENT**] Support new Sidekiq model for registering UI plugins [#472](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/472)
|
|
37
|
+
- [**ENHANCEMENT**] Stop testing against Ruby 2.7 and 3.0 [#472](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/472#discussion_r1663197863)
|
|
38
|
+
- [**ENHANCEMENT**] Display `at` and `in` in the dashboard [#291](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/291)
|
|
39
|
+
- [**ENHANCEMENT**] Docs enhancements [#442](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/442), [#449](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/449), [#457](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/457), [#465](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/465), [58e1835](https://github.com/sidekiq-scheduler/sidekiq-scheduler/commit/58e18351054fc3c264b2b5a684173316f674c386)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# 5.0.3
|
|
43
|
+
|
|
44
|
+
- [**FIX**] Fix "uppercase character in header name: Cache-Control" [#432](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/432)
|
|
45
|
+
- [**ENHANCEMENT**] Add gd translation [#433](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/433)
|
|
46
|
+
- [**ENHANCEMENT**] Add French translation [#435](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/435)
|
|
47
|
+
- [**FIX**] Remove usage of deprecated Redis command `zrangebyscore` [#437](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/437)
|
|
48
|
+
- [**ENHANCEMENT**] Add the ability to force a job args hash to be deconstructed to keyword arguments [#440](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/440)
|
|
49
|
+
|
|
50
|
+
# 5.0.2
|
|
51
|
+
|
|
52
|
+
- [**FIX**] Fix YARD docblocks. [#427](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/427)
|
|
53
|
+
- [**FIX**] Fix dependency requirement on Sidekiq reverted unintentionally. [#429](https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/429)
|
|
54
|
+
|
|
55
|
+
# 5.0.1
|
|
56
|
+
|
|
57
|
+
- [**ENHANCEMENT**] Adds Ruby 3.2 to the CI matrix. [#420](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/420)
|
|
58
|
+
- [**DOCS**] README: refer to v5 as released. [#421](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/421)
|
|
59
|
+
- [**FIX**] Fix dependency on Rails `.present?` method. [#425](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/425)
|
|
60
|
+
|
|
61
|
+
# 5.0.0
|
|
62
|
+
|
|
63
|
+
- [**FIX**] Ensure generated scheduled time has a precision of 3 milliseconds. [#418](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/418)
|
|
64
|
+
|
|
65
|
+
*Note 1:* Check [# 5.0.0.beta1](#500beta1) & [# 5.0.0.beta2](#500beta2) releases for breaking changes.
|
|
66
|
+
|
|
67
|
+
*Note 2:* Sidekiq Embedding is yet not supported, see [#419](https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/419) for more details.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# 5.0.0.beta2
|
|
71
|
+
|
|
72
|
+
- [**FIX**] Drop explicit redis dependency [#416](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/416)
|
|
73
|
+
|
|
74
|
+
# 5.0.0.beta1
|
|
75
|
+
|
|
76
|
+
- [**BREAKING CHANGE**] Moves all sidekiq-scheduler config options under the `scheduler` key in the `sidekiq.yml` file [#412](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/412)
|
|
77
|
+
- If you're migrating from v4 to v5, any `sidekiq-scheduler` config you may have in your `sidekiq.yml` should be moved under the `scheduler` key.
|
|
78
|
+
- See [#412](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/412) to see which are the config options that you need to move under the `scheduler` key.
|
|
79
|
+
|
|
80
|
+
- [**BREAKING CHANGE**] Drop support for EOL Ruby & Sidekiq versions (Ruby: `2.5.x` & `2.6.x`; Sidekiq: `4.x` & `5.x`) [#411](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/411)
|
|
81
|
+
|
|
82
|
+
- [**FIX**] Add support for Sidekiq 7 [#410](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/410)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# 4.0.3
|
|
86
|
+
|
|
87
|
+
- [**GH Actions**] Add dependabot for GitHub Actions [#390](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/390)
|
|
88
|
+
- [**ENHANCEMENT**] Add «Enable all» and «Disable all» buttons [#398](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/398)
|
|
89
|
+
- [**ENHANCEMENT**] Allow for multiple applications to share a Redis DB [#401](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/401)
|
|
90
|
+
- [**FIX**] Fix metadata for Sidekiq strict_args! [#403](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/403)
|
|
91
|
+
- [**FIX**] Redis 5.0 compatibility [#404](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/404)
|
|
92
|
+
- [**FIX**] Fix the constantize method [#408](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/408)
|
|
93
|
+
|
|
94
|
+
# 4.0.2
|
|
95
|
+
|
|
96
|
+
- [**FIX**] Fix sidekiq deprecation warning when Sidekiq 6.5+ [#385](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/385)
|
|
97
|
+
- [**FIX**] Fix `#print_schedule` calling a method that doesn't exist in rufus scheduler [#388](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/388)
|
|
98
|
+
|
|
99
|
+
# 4.0.1
|
|
100
|
+
|
|
101
|
+
- [**FIX**] Add support for sidekiq 6.5 [#382](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/382)
|
|
102
|
+
|
|
1
103
|
# 4.0.0
|
|
2
104
|
|
|
3
|
-
- [**FIX**] Fix CSS not loading on Rails app when Sidekiq < 6 [#377](https://github.com/
|
|
4
|
-
- [**BREAKING CHANGE**] Drop support for Sidekiq 3 [f15e7ca1a5f3ab5b6fd3d7664d67723dba1fa1f1](https://github.com/
|
|
105
|
+
- [**FIX**] Fix CSS not loading on Rails app when Sidekiq < 6 [#377](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/377)
|
|
106
|
+
- [**BREAKING CHANGE**] Drop support for Sidekiq 3 [f15e7ca1a5f3ab5b6fd3d7664d67723dba1fa1f1](https://github.com/sidekiq-scheduler/sidekiq-scheduler/commit/f15e7ca1a5f3ab5b6fd3d7664d67723dba1fa1f1)
|
|
5
107
|
|
|
6
108
|
# 4.0.0.alpha1
|
|
7
109
|
|
|
8
|
-
- [**FIX**] Fix deprecated uses of Redis#pipelined [#357](https://github.com/
|
|
9
|
-
- [**DOCS**] Add docs for running multi-sidekiq configurations [#362](https://github.com/
|
|
10
|
-
- [**FIX**] Prevent sidekiq_options from overriding ActiveJob queue settings [#367](https://github.com/
|
|
11
|
-
- [**ENHANCEMENT**] Highlight disabled jobs [#369](https://github.com/
|
|
12
|
-
- [**BREAKING CHANGE**] Require redis 4.2.0 [#370](https://github.com/
|
|
13
|
-
- [**FIX**] Fixes redis deprecation warning regarding `exists` [#370](https://github.com/
|
|
14
|
-
- [**BREAKING CHANGE**] Remove
|
|
15
|
-
- Support Ruby 3.1 [#373](https://github.com/
|
|
16
|
-
- [**BREAKING CHANGE**] Set rufus_scheduler_options via sidekiq.yml file as configuration option [#375](https://github.com/
|
|
110
|
+
- [**FIX**] Fix deprecated uses of Redis#pipelined [#357](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/357)
|
|
111
|
+
- [**DOCS**] Add docs for running multi-sidekiq configurations [#362](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/362)
|
|
112
|
+
- [**FIX**] Prevent sidekiq_options from overriding ActiveJob queue settings [#367](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/367)
|
|
113
|
+
- [**ENHANCEMENT**] Highlight disabled jobs [#369](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/369)
|
|
114
|
+
- [**BREAKING CHANGE**] Require redis 4.2.0 [#370](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/370)
|
|
115
|
+
- [**FIX**] Fixes redis deprecation warning regarding `exists` [#370](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/370)
|
|
116
|
+
- [**BREAKING CHANGE**] Remove dependency on thwait and e2mmap [#371](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/371)
|
|
117
|
+
- Support Ruby 3.1 [#373](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/373)
|
|
118
|
+
- [**BREAKING CHANGE**] Set rufus_scheduler_options via sidekiq.yml file as configuration option [#375](https://github.com/sidekiq-scheduler/sidekiq-scheduler/pull/375)
|
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# sidekiq-scheduler
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<a href="http://
|
|
5
|
-
<img src="https://
|
|
4
|
+
<a href="http://sidekiq-scheduler.github.io/sidekiq-scheduler/">
|
|
5
|
+
<img src="https://sidekiq-scheduler.github.io/sidekiq-scheduler/images/small-logo.svg" width="468px" height="200px" alt="Sidekiq Scheduler" />
|
|
6
6
|
</a>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
@@ -10,19 +10,7 @@
|
|
|
10
10
|
<a href="https://badge.fury.io/rb/sidekiq-scheduler">
|
|
11
11
|
<img src="https://badge.fury.io/rb/sidekiq-scheduler.svg" alt="Gem Version">
|
|
12
12
|
</a>
|
|
13
|
-
<a href="
|
|
14
|
-
<img src="https://codeclimate.com/github/moove-it/sidekiq-scheduler/badges/gpa.svg" alt="Code Climate">
|
|
15
|
-
</a>
|
|
16
|
-
<a href="https://travis-ci.org/moove-it/sidekiq-scheduler">
|
|
17
|
-
<img src="https://api.travis-ci.org/moove-it/sidekiq-scheduler.svg?branch=master" alt="Build Status">
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://coveralls.io/github/moove-it/sidekiq-scheduler?branch=master">
|
|
20
|
-
<img src="https://coveralls.io/repos/moove-it/sidekiq-scheduler/badge.svg?branch=master&service=github" alt="Coverage Status">
|
|
21
|
-
</a>
|
|
22
|
-
<a href="https://inch-ci.org/github/moove-it/sidekiq-scheduler">
|
|
23
|
-
<img src="https://inch-ci.org/github/moove-it/sidekiq-scheduler.svg?branch=master" alt="Documentation Coverage">
|
|
24
|
-
</a>
|
|
25
|
-
<a href="http://www.rubydoc.info/github/moove-it/sidekiq-scheduler">
|
|
13
|
+
<a href="http://www.rubydoc.info/github/sidekiq-scheduler/sidekiq-scheduler">
|
|
26
14
|
<img src="https://img.shields.io/badge/yard-docs-blue.svg" alt="Documentation">
|
|
27
15
|
</a>
|
|
28
16
|
</p>
|
|
@@ -30,7 +18,7 @@
|
|
|
30
18
|
`sidekiq-scheduler` is an extension to [Sidekiq](http://github.com/mperham/sidekiq) that
|
|
31
19
|
pushes jobs in a scheduled way, mimicking cron utility.
|
|
32
20
|
|
|
33
|
-
__Note:__ Current branch contains work of the
|
|
21
|
+
__Note:__ Current branch contains work of the v6 release, if you are looking for version 2.2.\*, 3.\*, 4.\*, or 5.\*, go to [2.2-stable branch](https://github.com/sidekiq-scheduler/sidekiq-scheduler/tree/2.2-stable) / [v3-stable](https://github.com/sidekiq-scheduler/sidekiq-scheduler/tree/v3-stable) / [v4-stable](https://github.com/sidekiq-scheduler/sidekiq-scheduler/tree/v4-stable) / [v5-stable](https://github.com/sidekiq-scheduler/sidekiq-scheduler/tree/v5-stable).
|
|
34
22
|
|
|
35
23
|
## Installation
|
|
36
24
|
|
|
@@ -49,7 +37,7 @@ gem install sidekiq-scheduler
|
|
|
49
37
|
require 'sidekiq-scheduler'
|
|
50
38
|
|
|
51
39
|
class HelloWorld
|
|
52
|
-
include Sidekiq::
|
|
40
|
+
include Sidekiq::Job
|
|
53
41
|
|
|
54
42
|
def perform
|
|
55
43
|
puts 'Hello world'
|
|
@@ -57,15 +45,21 @@ class HelloWorld
|
|
|
57
45
|
end
|
|
58
46
|
```
|
|
59
47
|
|
|
48
|
+
__Note:__ In Sidekiq v6.3 `Sidekiq::Job` was introduced as an alias for `Sidekiq::Worker`. `Sidekiq::Worker` has been officially deprecated in Sidekiq v7 although it still exists for backwards compatibility. It is therefore recommended to use `include Sidekiq::Job` in the above example unless an older version of Sidekiq is required.
|
|
49
|
+
|
|
60
50
|
``` yaml
|
|
61
51
|
# config/sidekiq.yml
|
|
62
52
|
|
|
63
|
-
:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
:scheduler:
|
|
54
|
+
:schedule:
|
|
55
|
+
hello_world:
|
|
56
|
+
cron: '0 * * * * *' # Runs once per minute
|
|
57
|
+
class: HelloWorld
|
|
67
58
|
```
|
|
68
59
|
|
|
60
|
+
> [!NOTE]
|
|
61
|
+
> sidekiq-scheduler uses [fugit](https://github.com/floraison/fugit) under the hood, which supports up to six arguments as the cron string, [see](https://github.com/floraison/fugit?tab=readme-ov-file#the-second-extension).
|
|
62
|
+
|
|
69
63
|
Run sidekiq:
|
|
70
64
|
|
|
71
65
|
``` sh
|
|
@@ -95,40 +89,60 @@ Configuration options are placed inside `sidekiq.yml` config file.
|
|
|
95
89
|
Available options are:
|
|
96
90
|
|
|
97
91
|
``` yaml
|
|
98
|
-
:dynamic: <if true the schedule can be modified in runtime [false by default]>
|
|
99
|
-
:dynamic_every: <if dynamic is true, the schedule is reloaded every interval [5s by default]>
|
|
100
|
-
:enabled: <enables scheduler if true [true by default]>
|
|
101
92
|
:scheduler:
|
|
93
|
+
:dynamic: <if true the schedule can be modified in runtime [false by default]>
|
|
94
|
+
:dynamic_every: <if dynamic is true, the schedule is reloaded every interval [5s by default]>
|
|
95
|
+
:enabled: <enables scheduler if true [true by default]>
|
|
102
96
|
:listened_queues_only: <push jobs whose queue is being listened by sidekiq [false by default]>
|
|
103
|
-
:rufus_scheduler_options: <Set custom options for rufus scheduler, like max_work_threads [{} by default]>
|
|
97
|
+
:rufus_scheduler_options: <Set custom options for rufus scheduler, like max_work_threads [{} by default]>
|
|
104
98
|
```
|
|
105
99
|
|
|
106
100
|
## Schedule configuration
|
|
107
101
|
|
|
108
|
-
The schedule is configured through the `:schedule` config entry in the sidekiq config file:
|
|
102
|
+
The schedule is configured through the `:scheduler:` -> `:schedule` config entry in the sidekiq config file:
|
|
109
103
|
|
|
110
104
|
``` yaml
|
|
111
|
-
:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
105
|
+
:scheduler:
|
|
106
|
+
:schedule:
|
|
107
|
+
CancelAbandonedOrders:
|
|
108
|
+
cron: '0 */5 * * * *' # Runs when second = 0, every 5 minutes
|
|
109
|
+
|
|
110
|
+
queue_documents_for_indexing:
|
|
111
|
+
cron: '0 0 * * * *' # Runs every hour
|
|
112
|
+
|
|
113
|
+
# By default the job name will be taken as worker class name.
|
|
114
|
+
# If you want to have a different job name and class name, provide the 'class' option
|
|
115
|
+
class: QueueDocuments
|
|
116
|
+
|
|
117
|
+
queue: slow
|
|
118
|
+
args: ['*.pdf']
|
|
119
|
+
description: "This job queues pdf content for indexing in solr"
|
|
120
|
+
|
|
121
|
+
# Enable the `metadata` argument which will pass a Hash containing the schedule metadata
|
|
122
|
+
# as the last argument of the `perform` method. `false` by default.
|
|
123
|
+
include_metadata: true
|
|
124
|
+
|
|
125
|
+
# Enable / disable a job. All jobs are enabled by default.
|
|
126
|
+
enabled: true
|
|
127
|
+
|
|
128
|
+
# Deconstructs a hash defined as the `args` to keyword arguments.
|
|
129
|
+
#
|
|
130
|
+
# `false` by default.
|
|
131
|
+
#
|
|
132
|
+
# Example
|
|
133
|
+
#
|
|
134
|
+
# my_job:
|
|
135
|
+
# cron: '0 0 * * * *'
|
|
136
|
+
# class: MyJob
|
|
137
|
+
# args: { foo: 'bar', hello: 'world' }
|
|
138
|
+
# keyword_argument: true
|
|
139
|
+
#
|
|
140
|
+
# class MyJob < ActiveJob::Base
|
|
141
|
+
# def perform(foo:, hello:)
|
|
142
|
+
# # ...
|
|
143
|
+
# end
|
|
144
|
+
# end
|
|
145
|
+
keyword_argument: true
|
|
132
146
|
```
|
|
133
147
|
|
|
134
148
|
### Schedule metadata
|
|
@@ -169,9 +183,10 @@ Cron, every, and interval types push jobs into sidekiq in a recurrent manner.
|
|
|
169
183
|
`cron` follows the same pattern as cron utility, with seconds resolution.
|
|
170
184
|
|
|
171
185
|
``` yaml
|
|
172
|
-
:
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
:scheduler:
|
|
187
|
+
:schedule:
|
|
188
|
+
HelloWorld:
|
|
189
|
+
cron: '0 * * * * *' # Runs when second = 0
|
|
175
190
|
```
|
|
176
191
|
|
|
177
192
|
`every` triggers following a given frequency:
|
|
@@ -198,7 +213,7 @@ At, and in types push jobs only once. `at` schedules in a point in time:
|
|
|
198
213
|
at: '3001/01/01'
|
|
199
214
|
```
|
|
200
215
|
|
|
201
|
-
You can specify any string that `DateTime.parse` and `Chronic` understand. To enable Chronic
|
|
216
|
+
You can specify any string that `DateTime.parse` and `Chronic` understand. To enable [Chronic](https://github.com/mojombo/chronic)
|
|
202
217
|
strings, you must add it as a dependency.
|
|
203
218
|
|
|
204
219
|
`in` triggers after a time duration has elapsed:
|
|
@@ -262,7 +277,8 @@ When `:dynamic` flag is set to `true`, schedule changes are loaded every 5 secon
|
|
|
262
277
|
|
|
263
278
|
``` yaml
|
|
264
279
|
# config/sidekiq.yml
|
|
265
|
-
:
|
|
280
|
+
:scheduler:
|
|
281
|
+
:dynamic: true
|
|
266
282
|
```
|
|
267
283
|
|
|
268
284
|
If `:dynamic` flag is set to `false`, you'll have to reload the schedule manually in sidekiq
|
|
@@ -311,8 +327,9 @@ You can also override the thread pool size in Rufus Scheduler by setting the fol
|
|
|
311
327
|
---
|
|
312
328
|
...
|
|
313
329
|
|
|
314
|
-
|
|
315
|
-
|
|
330
|
+
:scheduler:
|
|
331
|
+
rufus_scheduler_options:
|
|
332
|
+
max_work_threads: 5
|
|
316
333
|
|
|
317
334
|
...
|
|
318
335
|
```
|
|
@@ -320,7 +337,7 @@ rufus_scheduler_options:
|
|
|
320
337
|
## Notes about running on Multiple Hosts
|
|
321
338
|
|
|
322
339
|
Under normal conditions, `cron` and `at` jobs are pushed once regardless of the number of `sidekiq-scheduler` running instances,
|
|
323
|
-
|
|
340
|
+
assuming that time deltas between hosts is less than 24 hours.
|
|
324
341
|
|
|
325
342
|
Non-normal conditions that could push a specific job multiple times are:
|
|
326
343
|
- high cpu load + a high number of jobs scheduled at the same time, like 100 jobs
|
|
@@ -328,6 +345,47 @@ Non-normal conditions that could push a specific job multiple times are:
|
|
|
328
345
|
|
|
329
346
|
`every`, `interval` and `in` jobs will be pushed once per host.
|
|
330
347
|
|
|
348
|
+
### Suggested setup for Multiple Hosts using Heroku and Rails
|
|
349
|
+
|
|
350
|
+
Configuration options `every`, `interval` and `in` will push once per host. This may be undesirable. One way to achieve single jobs per the schedule would be to manually designate a host as the scheduler. The goal is to have a single scheduler process running across all your hosts.
|
|
351
|
+
|
|
352
|
+
This can be achieved by using an environment variable and controlling the number of dynos. In Rails, you can read this variable during initialization and then conditionally load your config file.
|
|
353
|
+
|
|
354
|
+
Suppose we are using Rails and have the following schedule:
|
|
355
|
+
|
|
356
|
+
```yaml
|
|
357
|
+
# config/scheduler.yml
|
|
358
|
+
MyRegularJob:
|
|
359
|
+
description: "We want this job to run very often, but we do not want to run more of them as we scale"
|
|
360
|
+
interval: ["1m"]
|
|
361
|
+
queue: default
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Then we can conditionally load it via an initializer:
|
|
365
|
+
|
|
366
|
+
```ruby
|
|
367
|
+
# config/initializers/sidekiq.rb
|
|
368
|
+
if ENV.fetch("IS_SCHEDULER", false)
|
|
369
|
+
Sidekiq.configure_server do |config|
|
|
370
|
+
config.on(:startup) do
|
|
371
|
+
Sidekiq.schedule = YAML.load_file(File.expand_path("../scheduler.yml", File.dirname(__FILE__)))
|
|
372
|
+
Sidekiq::Scheduler.reload_schedule!
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Then you would just need to flag the scheduler process when you start it. If you are using a Procfile, it would look like this:
|
|
379
|
+
|
|
380
|
+
```yaml
|
|
381
|
+
# Procfile
|
|
382
|
+
web: bin/rails server
|
|
383
|
+
worker: bundle exec sidekiq -q default
|
|
384
|
+
scheduler: IS_SCHEDULER=true bundle exec sidekiq -q default
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
When running via Heroku, you set your `scheduler` process to have 1 dyno. This will ensure you have at most 1 worker loading the schedule.
|
|
388
|
+
|
|
331
389
|
## Notes on when Sidekiq worker is down
|
|
332
390
|
|
|
333
391
|
For a `cron`/`at` (and all other) job to be successfully enqueued, you need at least one sidekiq worker with scheduler to be up at that moment. Handling this is up to you and depends on your application.
|
|
@@ -339,7 +397,7 @@ Possible solutions include:
|
|
|
339
397
|
- Zero downtime deploy for sidekiq workers: keep at least one worker up during whole deploy and only restart/shut it down after when new one has started
|
|
340
398
|
- Running scheduler inside your unicorn/rails processes (if you already have zero downtime deploy set up for these)
|
|
341
399
|
|
|
342
|
-
Each option has it's own pros and cons.
|
|
400
|
+
Each option has it's own pros and cons.
|
|
343
401
|
|
|
344
402
|
## Notes when running multiple Sidekiq processors on the same Redis
|
|
345
403
|
|
|
@@ -357,12 +415,13 @@ Say you have one process with the schedule:
|
|
|
357
415
|
|
|
358
416
|
:queues:
|
|
359
417
|
- default
|
|
360
|
-
:
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
418
|
+
:scheduler:
|
|
419
|
+
:schedule:
|
|
420
|
+
do_something_every_minute:
|
|
421
|
+
class: DoSomethingJob
|
|
422
|
+
args: matey
|
|
423
|
+
queue: :scheduler
|
|
424
|
+
cron: '0 * * * * * America/Los_Angeles'
|
|
366
425
|
```
|
|
367
426
|
|
|
368
427
|
And a separate separate configured process without one:
|
|
@@ -372,7 +431,8 @@ And a separate separate configured process without one:
|
|
|
372
431
|
- scheduler
|
|
373
432
|
|
|
374
433
|
## NOTE Disable the Scheduler
|
|
375
|
-
:
|
|
434
|
+
:scheduler:
|
|
435
|
+
:enabled: false
|
|
376
436
|
```
|
|
377
437
|
|
|
378
438
|
### Details
|
|
@@ -387,7 +447,23 @@ Scheduler** for the other processes not responsible for the schedule. If you
|
|
|
387
447
|
don't, the last booted Sidekiq processes' schedule will be what is stored in
|
|
388
448
|
Redis.
|
|
389
449
|
|
|
390
|
-
See https://github.com/
|
|
450
|
+
See https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/361 for a more details.
|
|
451
|
+
|
|
452
|
+
## Notes when running multiple applications in the same Redis database
|
|
453
|
+
|
|
454
|
+
_NOTE_: **Although we support this option, we recommend having separate redis databases for each application. Choosing this option is at your own risk.**
|
|
455
|
+
|
|
456
|
+
If you need to run multiple applications with differing schedules, the easiest way is to use a different Redis database per application. Doing that will ensure that each application will have its own schedule, web interface and statistics.
|
|
457
|
+
|
|
458
|
+
However, you may want to have a set of related applications share the same Redis database in order to aggregate statistics and manage them all in a single web interface. To do this while maintaining a different schedule for each application, you can configure each application to use a different `key_prefix` in Redis. This prevents the applications overwriting each others' schedules and schedule data.
|
|
459
|
+
|
|
460
|
+
```ruby
|
|
461
|
+
Rails.application.reloader.to_prepare do
|
|
462
|
+
SidekiqScheduler::RedisManager.key_prefix = "my-app"
|
|
463
|
+
end
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Note that this must be set before the schedule is loaded (or it will go into the wrong key). If you are using the web integration, make sure that the prefix is set in the web process so that you see the correct schedule.
|
|
391
467
|
|
|
392
468
|
## Sidekiq Web Integration
|
|
393
469
|
|
|
@@ -402,7 +478,9 @@ require 'sidekiq-scheduler/web'
|
|
|
402
478
|
run Sidekiq::Web
|
|
403
479
|
```
|
|
404
480
|
|
|
405
|
-

|
|
482
|
+
|
|
483
|
+

|
|
406
484
|
|
|
407
485
|
## ActiveJob integration
|
|
408
486
|
|
|
@@ -418,7 +496,7 @@ end
|
|
|
418
496
|
|
|
419
497
|
## The Spring preloader and Testing your initializer via Rails console
|
|
420
498
|
|
|
421
|
-
If you're pulling in your schedule from a YML file via an initializer as shown, be aware that the Spring application preloader included with Rails will
|
|
499
|
+
If you're pulling in your schedule from a YML file via an initializer as shown, be aware that the Spring application preloader included with Rails will interfere with testing via the Rails console.
|
|
422
500
|
|
|
423
501
|
**Spring will not reload initializers** unless the initializer is changed. Therefore, if you're making a change to your YML schedule file and reloading Rails console to see the change, Spring will make it seem like your modified schedule is not being reloaded.
|
|
424
502
|
|
|
@@ -426,7 +504,7 @@ To see your updated schedule, be sure to reload Spring by stopping it prior to b
|
|
|
426
504
|
|
|
427
505
|
Run `spring stop` to stop Spring.
|
|
428
506
|
|
|
429
|
-
For more information, see [this issue](https://github.com/
|
|
507
|
+
For more information, see [this issue](https://github.com/sidekiq-scheduler/sidekiq-scheduler/issues/35#issuecomment-48067183) and [Spring's README](https://github.com/rails/spring/blob/master/README.md).
|
|
430
508
|
|
|
431
509
|
|
|
432
510
|
## Manage tasks from Unicorn/Rails server
|
|
@@ -463,7 +541,7 @@ MIT License
|
|
|
463
541
|
|
|
464
542
|
## Copyright
|
|
465
543
|
|
|
466
|
-
- Copyright 2021 -
|
|
544
|
+
- Copyright 2021 - 2024 Marcelo Lauxen.
|
|
467
545
|
- Copyright 2013 - 2022 Moove-IT.
|
|
468
546
|
- Copyright 2012 Morton Jonuschat.
|
|
469
547
|
- Some parts copyright 2010 Ben VandenBos.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module SidekiqScheduler
|
|
2
|
+
class Config
|
|
3
|
+
# We have to set the default as nil because the scheduler could be instantiated without
|
|
4
|
+
# passing the sidekiq config, and in those scenarios we don't want to fail
|
|
5
|
+
def initialize(sidekiq_config: nil, without_defaults: false)
|
|
6
|
+
@sidekiq_config = sidekiq_config
|
|
7
|
+
@scheduler_config = fetch_scheduler_config(sidekiq_config, without_defaults)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def enabled?
|
|
11
|
+
scheduler_config[:enabled]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def enabled=(value)
|
|
15
|
+
scheduler_config[:enabled] = value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def dynamic?
|
|
19
|
+
scheduler_config[:dynamic]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def dynamic=(value)
|
|
23
|
+
scheduler_config[:dynamic] = value
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def dynamic_every?
|
|
27
|
+
scheduler_config[:dynamic_every]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def dynamic_every=(value)
|
|
31
|
+
scheduler_config[:dynamic_every] = value
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def schedule
|
|
35
|
+
scheduler_config[:schedule]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def schedule=(value)
|
|
39
|
+
scheduler_config[:schedule] = value
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def listened_queues_only?
|
|
43
|
+
scheduler_config[:listened_queues_only]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def listened_queues_only=(value)
|
|
47
|
+
scheduler_config[:listened_queues_only] = value
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def rufus_scheduler_options
|
|
51
|
+
scheduler_config[:rufus_scheduler_options]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def rufus_scheduler_options=(value)
|
|
55
|
+
scheduler_config[:rufus_scheduler_options] = value
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def sidekiq_queues
|
|
59
|
+
SidekiqScheduler::SidekiqAdapter.sidekiq_queues(sidekiq_config)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def to_hash
|
|
63
|
+
{
|
|
64
|
+
enabled: enabled?,
|
|
65
|
+
dynamic: dynamic?,
|
|
66
|
+
dynamic_every: dynamic_every?,
|
|
67
|
+
schedule: schedule,
|
|
68
|
+
listened_queues_only: listened_queues_only?,
|
|
69
|
+
rufus_scheduler_options: rufus_scheduler_options
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
attr_reader :scheduler_config
|
|
76
|
+
attr_reader :sidekiq_config
|
|
77
|
+
|
|
78
|
+
DEFAULT_OPTIONS = {
|
|
79
|
+
enabled: true,
|
|
80
|
+
dynamic: false,
|
|
81
|
+
dynamic_every: '5s',
|
|
82
|
+
schedule: {},
|
|
83
|
+
rufus_scheduler_options: {}
|
|
84
|
+
}.freeze
|
|
85
|
+
|
|
86
|
+
def fetch_scheduler_config(sidekiq_config, without_defaults)
|
|
87
|
+
conf = SidekiqScheduler::SidekiqAdapter.fetch_scheduler_config_from_sidekiq(sidekiq_config)
|
|
88
|
+
without_defaults ? conf : DEFAULT_OPTIONS.merge(conf)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
require 'sidekiq/web' unless defined?(Sidekiq::Web)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Locale and asset cache is configured in `cfg.register`
|
|
4
|
+
args = {
|
|
5
|
+
name: "recurring_jobs",
|
|
6
|
+
tab: ["Recurring Jobs"],
|
|
7
|
+
index: ["recurring-jobs"],
|
|
8
|
+
root_dir: File.expand_path("../../../web", File.dirname(__FILE__)),
|
|
9
|
+
asset_paths: ["stylesheets-scheduler"]
|
|
10
|
+
}
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
Sidekiq::Web.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if SidekiqScheduler::SidekiqAdapter::SIDEKIQ_GTE_8_0_0
|
|
13
|
+
Sidekiq::Web.configure do |cfg|
|
|
14
|
+
cfg.register(SidekiqScheduler::Web, **args) do |app|
|
|
15
|
+
# add middleware or additional settings here
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
else
|
|
19
|
+
Sidekiq::Web.register(SidekiqScheduler::Web, **args) do |app|
|
|
20
|
+
# add middleware or additional settings here
|
|
21
|
+
end
|
|
14
22
|
end
|
|
@@ -38,7 +38,7 @@ module SidekiqScheduler
|
|
|
38
38
|
#
|
|
39
39
|
# @return [String] with the job's interval
|
|
40
40
|
def interval
|
|
41
|
-
@attributes['cron'] || @attributes['interval'] || @attributes['every']
|
|
41
|
+
@attributes['cron'] || @attributes['interval'] || @attributes['every'] || @attributes['at'] || @attributes['in']
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
# Returns the queue of the job
|