sidekiq-cron 2.3.1 → 2.4.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.md +7 -0
- data/README.md +17 -0
- data/lib/sidekiq/cron/launcher.rb +1 -0
- data/lib/sidekiq/cron/locales/es.yml +2 -2
- data/lib/sidekiq/cron/poller.rb +4 -0
- data/lib/sidekiq/cron/schedule_loader.rb +5 -0
- data/lib/sidekiq/cron/version.rb +1 -1
- data/lib/sidekiq/cron/views/cron.erb +6 -5
- data/lib/sidekiq/cron/views/legacy/cron.erb +6 -5
- data/lib/sidekiq/cron.rb +22 -0
- data/sidekiq-cron.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24a9263df38117d217eaff38d09f5cc69029d2998a3cc07fd5f21878b340305c
|
|
4
|
+
data.tar.gz: 9cf118cc907fd84abdc0c0123fb23d6745b9fee021557560e35c55f9ff99fd35
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 238cd9ccbf1f621090eca667e9e1b4c198589897869c7e8d89746886297bac0456dcd0452aa91f0e5e07af5e4e686d93f140089a44cd676cdf1711c45ced4e40
|
|
7
|
+
data.tar.gz: 404d91026a551fefd3e2a4c37bae8220e522b9a38a377cbbdc2f692331926495835feb2a4decf8dfe4a059e84ff6c45fc99e6c96c0f6156d53130586bf70b1bb
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 2.4.0
|
|
6
|
+
|
|
7
|
+
- Fix reflected XSS on Sidekiq-UI (https://github.com/sidekiq-cron/sidekiq-cron/pull/568)
|
|
8
|
+
- Add `cron_process_count_override` config option (https://github.com/sidekiq-cron/sidekiq-cron/pull/572)
|
|
9
|
+
- Fix Spanish translation for enabled/disabled states (https://github.com/sidekiq-cron/sidekiq-cron/pull/575)
|
|
10
|
+
- Allow to conditionally disable Sidekiq-Cron (https://github.com/sidekiq-cron/sidekiq-cron/pull/574)
|
|
11
|
+
|
|
5
12
|
## 2.3.1
|
|
6
13
|
|
|
7
14
|
- Fix manually launch enqueue job not working from web UI (https://github.com/sidekiq-cron/sidekiq-cron/pull/564)
|
data/README.md
CHANGED
|
@@ -69,6 +69,7 @@ All configuration options:
|
|
|
69
69
|
|
|
70
70
|
```ruby
|
|
71
71
|
Sidekiq::Cron.configure do |config|
|
|
72
|
+
config.enabled = false # Default is true
|
|
72
73
|
config.cron_poll_interval = 10 # Default is 30
|
|
73
74
|
config.cron_schedule_file = 'config/my_schedule.yml' # Default is 'config/schedule.yml'
|
|
74
75
|
config.cron_history_size = 20 # Default is 10
|
|
@@ -521,6 +522,22 @@ Sidekiq::Cron.configure do |config|
|
|
|
521
522
|
end
|
|
522
523
|
```
|
|
523
524
|
|
|
525
|
+
You can also disable the entire engine by setting `enabled` to `false`. When disabled, Sidekiq-Cron will skip loading the schedule file on startup, which is useful for environments or specific Sidekiq processes where you don't need cron job scheduling at all:
|
|
526
|
+
|
|
527
|
+
```ruby
|
|
528
|
+
Sidekiq::Cron.configure do |config|
|
|
529
|
+
config.enabled = false
|
|
530
|
+
end
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
Sidekiq will internally determine the process count by checking Redis but if polling has been disabled from some Sidekiq processes by setting the cron poll interval to zero, as explained above, that count might be incorrect. In that case, it is possible to override the default process count for Sidekiq Cron. This affects the way the random poll interval is calculated internally.
|
|
534
|
+
|
|
535
|
+
```ruby
|
|
536
|
+
Sidekiq::Cron.configure do |config|
|
|
537
|
+
config.cron_poll_process_count = 2
|
|
538
|
+
end
|
|
539
|
+
```
|
|
540
|
+
|
|
524
541
|
## Testing your configuration
|
|
525
542
|
|
|
526
543
|
You can test your application's configuration by loading the schedule in your test suite. Below is an example using RSpec in a Rails project:
|
|
@@ -13,6 +13,7 @@ module Sidekiq
|
|
|
13
13
|
# Add cron poller and execute normal initialize of Sidekiq launcher.
|
|
14
14
|
def initialize(config, **kwargs)
|
|
15
15
|
config[:cron_poll_interval] = Sidekiq::Cron.configuration.cron_poll_interval.to_i
|
|
16
|
+
config[:cron_poll_process_count] = Sidekiq::Cron.configuration.cron_poll_process_count
|
|
16
17
|
|
|
17
18
|
@cron_poller = Sidekiq::Cron::Poller.new(config) if config[:cron_poll_interval] > 0
|
|
18
19
|
super
|
data/lib/sidekiq/cron/poller.rb
CHANGED
|
@@ -50,6 +50,11 @@ end
|
|
|
50
50
|
|
|
51
51
|
Sidekiq.configure_server do |config|
|
|
52
52
|
config.on(:startup) do
|
|
53
|
+
unless Sidekiq::Cron.configuration.enabled
|
|
54
|
+
Sidekiq.logger.info { "Cron Jobs - skipping schedule loading, Sidekiq-Cron is disabled" }
|
|
55
|
+
next
|
|
56
|
+
end
|
|
57
|
+
|
|
53
58
|
schedule_loader = Sidekiq::Cron::ScheduleLoader.new
|
|
54
59
|
next unless schedule_loader.has_schedule_file?
|
|
55
60
|
schedule_loader.load_schedule
|
data/lib/sidekiq/cron/version.rb
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
2
2
|
<header>
|
|
3
3
|
<h2>
|
|
4
4
|
<%= t('CronJobs') %>
|
|
5
|
-
<small>(<%= @current_namespace %>)</small>
|
|
5
|
+
<small>(<%= CGI.escapeHTML(@current_namespace.to_s) %>)</small>
|
|
6
6
|
</h2>
|
|
7
7
|
<% if @cron_jobs.size > 0 %>
|
|
8
|
+
<% escaped_current_namespace = CGI.escape(@current_namespace) %>
|
|
8
9
|
<div class="filter buttons-row">
|
|
9
|
-
<form action="<%= root_path %>cron/namespaces/<%=
|
|
10
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/delete" method="post">
|
|
10
11
|
<%= csrf_tag %>
|
|
11
12
|
<input class="btn btn-danger" type="submit" name="delete" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSureDeleteCronJobs') %>" />
|
|
12
13
|
</form>
|
|
13
|
-
<form action="<%= root_path %>cron/namespaces/<%=
|
|
14
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/disable" method="post">
|
|
14
15
|
<%= csrf_tag %>
|
|
15
16
|
<input class="btn btn-primary" type="submit" name="enqueue" value="<%= t('DisableAll') %>" />
|
|
16
17
|
</form>
|
|
17
|
-
<form action="<%= root_path %>cron/namespaces/<%=
|
|
18
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/enable" method="post">
|
|
18
19
|
<%= csrf_tag %>
|
|
19
20
|
<input class="btn btn-primary" type="submit" name="enqueue" value="<%= t('EnableAll') %>" />
|
|
20
21
|
</form>
|
|
21
|
-
<form action="<%= root_path %>cron/namespaces/<%=
|
|
22
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/enqueue" method="post">
|
|
22
23
|
<%= csrf_tag %>
|
|
23
24
|
<input class="btn btn-primary" type="submit" name="enqueue" value="<%= t('EnqueueAll') %>" data-confirm="<%= t('AreYouSureEnqueueCronJobs') %>" />
|
|
24
25
|
</form>
|
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
<div class='col-sm-5 pull-left'>
|
|
3
3
|
<h3>
|
|
4
4
|
<%= t('CronJobs') %>
|
|
5
|
-
<small><%= @current_namespace %></small>
|
|
5
|
+
<small><%= CGI.escapeHTML(@current_namespace.to_s) %></small>
|
|
6
6
|
</h3>
|
|
7
7
|
</div>
|
|
8
8
|
<div class='col-sm-7 pull-right h2'>
|
|
9
9
|
<% if @cron_jobs.size > 0 %>
|
|
10
|
-
|
|
10
|
+
<% escaped_current_namespace = CGI.escape(@current_namespace) %>
|
|
11
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/delete" method="post" class="pull-right">
|
|
11
12
|
<%= csrf_tag %>
|
|
12
13
|
<input class="btn btn-danger" type="submit" name="delete" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSureDeleteCronJobs') %>" />
|
|
13
14
|
</form>
|
|
14
|
-
<form action="<%= root_path %>cron/namespaces/<%=
|
|
15
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/disable" method="post" class="pull-right">
|
|
15
16
|
<%= csrf_tag %>
|
|
16
17
|
<input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('DisableAll') %>" />
|
|
17
18
|
</form>
|
|
18
|
-
<form action="<%= root_path %>cron/namespaces/<%=
|
|
19
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/enable" method="post" class="pull-right">
|
|
19
20
|
<%= csrf_tag %>
|
|
20
21
|
<input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('EnableAll') %>" />
|
|
21
22
|
</form>
|
|
22
|
-
<form action="<%= root_path %>cron/namespaces/<%=
|
|
23
|
+
<form action="<%= root_path %>cron/namespaces/<%= escaped_current_namespace %>/all/enqueue" method="post" class="pull-right">
|
|
23
24
|
<%= csrf_tag %>
|
|
24
25
|
<input class="btn btn-warn" type="submit" name="enqueue" value="<%= t('EnqueueAll') %>" data-confirm="<%= t('AreYouSureEnqueueCronJobs') %>" />
|
|
25
26
|
</form>
|
data/lib/sidekiq/cron.rb
CHANGED
|
@@ -14,6 +14,10 @@ module Sidekiq
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
class Configuration
|
|
17
|
+
# Whether Sidekiq-Cron is enabled. When set to false, the schedule file will not be loaded
|
|
18
|
+
# on startup. Defaults to true.
|
|
19
|
+
attr_accessor :enabled
|
|
20
|
+
|
|
17
21
|
# The interval, in seconds, at which to poll for scheduled cron jobs.
|
|
18
22
|
# This determines how frequently the scheduler checks for jobs to enqueue.
|
|
19
23
|
attr_accessor :cron_poll_interval
|
|
@@ -25,6 +29,15 @@ module Sidekiq
|
|
|
25
29
|
# This value controls how many past job executions are stored.
|
|
26
30
|
attr_accessor :cron_history_size
|
|
27
31
|
|
|
32
|
+
# The number of polling processes for Sidekiq Cron.
|
|
33
|
+
#
|
|
34
|
+
# It is configurable to handle the case where only a subset of Sidekiq process
|
|
35
|
+
# are used for Sidekiq Cron polling where the default would be to poll from all processes.
|
|
36
|
+
#
|
|
37
|
+
# @note The process count is used internally to determine the random poll interval.
|
|
38
|
+
# @see https://github.com/sidekiq/sidekiq/blob/e03b317f2070655c51fad838b0ecfb99c6d6f853/lib/sidekiq/scheduled.rb#L129-L160
|
|
39
|
+
attr_reader :cron_poll_process_count
|
|
40
|
+
|
|
28
41
|
# The default namespace is used when no namespace is specified.
|
|
29
42
|
attr_accessor :default_namespace
|
|
30
43
|
|
|
@@ -54,6 +67,7 @@ module Sidekiq
|
|
|
54
67
|
attr_accessor :reschedule_grace_period
|
|
55
68
|
|
|
56
69
|
def initialize
|
|
70
|
+
@enabled = true
|
|
57
71
|
@cron_poll_interval = 30
|
|
58
72
|
@cron_schedule_file = 'config/schedule.yml'
|
|
59
73
|
@cron_history_size = 10
|
|
@@ -70,6 +84,14 @@ module Sidekiq
|
|
|
70
84
|
|
|
71
85
|
@natural_cron_parsing_mode = mode
|
|
72
86
|
end
|
|
87
|
+
|
|
88
|
+
def cron_poll_process_count=(count)
|
|
89
|
+
unless count.is_a?(Integer) && count.positive?
|
|
90
|
+
raise ArgumentError, "invalid cron process count: #{count.inspect}"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
@cron_poll_process_count = count
|
|
94
|
+
end
|
|
73
95
|
end
|
|
74
96
|
end
|
|
75
97
|
end
|
data/sidekiq-cron.gemspec
CHANGED
|
@@ -37,5 +37,5 @@ Gem::Specification.new do |s|
|
|
|
37
37
|
s.add_development_dependency("rack-test", ">= 1.1")
|
|
38
38
|
s.add_development_dependency("rake", "~> 13.0")
|
|
39
39
|
s.add_development_dependency("simplecov", "~> 0.21")
|
|
40
|
-
s.add_development_dependency("simplecov-cobertura", "~>
|
|
40
|
+
s.add_development_dependency("simplecov-cobertura", "~> 3.1")
|
|
41
41
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sidekiq-cron
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ondrej Bartas
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cronex
|
|
@@ -162,14 +162,14 @@ dependencies:
|
|
|
162
162
|
requirements:
|
|
163
163
|
- - "~>"
|
|
164
164
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: '
|
|
165
|
+
version: '3.1'
|
|
166
166
|
type: :development
|
|
167
167
|
prerelease: false
|
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
|
169
169
|
requirements:
|
|
170
170
|
- - "~>"
|
|
171
171
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: '
|
|
172
|
+
version: '3.1'
|
|
173
173
|
description: Enables to set jobs to be run in specified time (using CRON notation
|
|
174
174
|
or natural language)
|
|
175
175
|
email: ondrej@bartas.cz
|
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
229
229
|
- !ruby/object:Gem::Version
|
|
230
230
|
version: '0'
|
|
231
231
|
requirements: []
|
|
232
|
-
rubygems_version: 3.
|
|
232
|
+
rubygems_version: 3.5.16
|
|
233
233
|
signing_key:
|
|
234
234
|
specification_version: 4
|
|
235
235
|
summary: Scheduler/Cron for Sidekiq jobs
|