sidekiq-cron 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +6 -0
- data/Gemfile +0 -1
- data/README.md +44 -33
- data/VERSION +1 -1
- data/lib/sidekiq/cron/job.rb +2 -0
- data/lib/sidekiq/cron/views/cron.erb +5 -0
- data/lib/sidekiq/cron/views/cron.slim +5 -0
- data/sidekiq-cron.gemspec +3 -6
- data/test/test_helper.rb +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e36b7b669446980725e708550d8a4c468a155f42
|
4
|
+
data.tar.gz: b95a3e582638be3924da88fcd45d2c8e5f6e1826
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 333bab73a66a5fc2dcc80646a7cd1a64a34ba9e3c92f46bc31560b7b0b774caaf949864b11d2a63d2571a51c280ce9147b2a64ddc626e7c150b5d01dfcaf2cd6
|
7
|
+
data.tar.gz: 4f14cf44af1f6c610a7e411577f7a6555b15fb25d19f3909db96461db03c42d22098d50af826b3f54f6d37acbcdfed613f048a81db4bca7fbdf7952cad1ec11a
|
data/Changes.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,17 +2,17 @@ Sidekiq-Cron [![Gem Version](https://badge.fury.io/rb/sidekiq-cron.png)](http://
|
|
2
2
|
================================================================================================================================================================================================================================================================================================================================================================================================================================================
|
3
3
|
|
4
4
|
|
5
|
-
|
5
|
+
A scheduling add-on for [Sidekiq](http://sidekiq.org).
|
6
6
|
|
7
|
-
Runs a thread
|
7
|
+
Runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` parsed by [Rufus-Scheduler](https://github.com/jmettraux/rufus-scheduler), more about [cron notation](http://www.nncron.ru/help/EN/working/cron-format.htm).
|
8
8
|
|
9
9
|
Checks for new jobs to schedule every 10 seconds and doesn't schedule the same job multiple times when more than one Sidekiq worker is running.
|
10
10
|
|
11
|
-
Scheduling jobs are added only when at least one
|
11
|
+
Scheduling jobs are added only when at least one Sidekiq process is running.
|
12
12
|
|
13
|
-
If you want to know how scheduling work check
|
13
|
+
If you want to know how scheduling work, check out [under the hood](#under-the-hood)
|
14
14
|
|
15
|
-
Works with
|
15
|
+
Works with ActiveJob (Rails 4.2+)
|
16
16
|
|
17
17
|
Requirements
|
18
18
|
-----------------
|
@@ -22,15 +22,15 @@ Requirements
|
|
22
22
|
|
23
23
|
Change Log
|
24
24
|
----------
|
25
|
-
before upgrading to new version
|
26
|
-
[Change Log](https://github.com/ondrejbartas/sidekiq-cron/
|
25
|
+
before upgrading to new version, please read:
|
26
|
+
[Change Log](https://github.com/ondrejbartas/sidekiq-cron/blob/master/Changes.md)
|
27
27
|
|
28
28
|
Installation
|
29
29
|
------------
|
30
30
|
|
31
31
|
$ gem install sidekiq-cron
|
32
32
|
|
33
|
-
or add to your Gemfile
|
33
|
+
or add to your `Gemfile`
|
34
34
|
|
35
35
|
gem "sidekiq-cron", "~> 0.3.0"
|
36
36
|
|
@@ -39,7 +39,7 @@ Getting Started
|
|
39
39
|
-----------------
|
40
40
|
|
41
41
|
|
42
|
-
If you are not using Rails you need to add `require 'sidekiq-cron'` somewhere after `require 'sidekiq'`.
|
42
|
+
If you are not using Rails, you need to add `require 'sidekiq-cron'` somewhere after `require 'sidekiq'`.
|
43
43
|
|
44
44
|
_Job properties_:
|
45
45
|
|
@@ -56,12 +56,11 @@ _Job properties_:
|
|
56
56
|
|
57
57
|
### Time, cron and sidekiq-cron
|
58
58
|
|
59
|
-
Cron line is
|
60
|
-
You will need to adjust cronline to `30 6 * * *`.
|
59
|
+
Cron line is always evaluated against UTC time. So if you are in Prague (timezone +02:00) and you want a job to be enqueued at 8:30 AM, you will need to adjust cronline to `30 6 * * *`.
|
61
60
|
|
62
61
|
### What objects/classes can be scheduled
|
63
62
|
#### Sidekiq Worker
|
64
|
-
In example we
|
63
|
+
In this example, we are using `HardWorker` which looks like:
|
65
64
|
```ruby
|
66
65
|
class HardWorker
|
67
66
|
include Sidekiq::Worker
|
@@ -72,7 +71,7 @@ end
|
|
72
71
|
```
|
73
72
|
|
74
73
|
#### Active Job Worker
|
75
|
-
You can schedule: `ExampleJob` which
|
74
|
+
You can schedule: `ExampleJob` which looks like:
|
76
75
|
```ruby
|
77
76
|
class ExampleJob < ActiveJob::Base
|
78
77
|
queue_as :default
|
@@ -93,14 +92,14 @@ class HardWorker
|
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
96
|
-
Sidekiq::Cron::Job.create(
|
95
|
+
Sidekiq::Cron::Job.create(name: 'Hard worker - every 5min', cron: '*/5 * * * *', klass: 'HardWorker')
|
97
96
|
# => true
|
98
97
|
```
|
99
98
|
|
100
99
|
`create` method will return only true/false if job was saved or not.
|
101
100
|
|
102
101
|
```ruby
|
103
|
-
job = Sidekiq::Cron::Job.new(
|
102
|
+
job = Sidekiq::Cron::Job.new(name: 'Hard worker - every 5min', cron: '*/5 * * * *', klass: 'HardWorker')
|
104
103
|
|
105
104
|
if job.valid?
|
106
105
|
job.save
|
@@ -152,8 +151,9 @@ array = [
|
|
152
151
|
Sidekiq::Cron::Job.load_from_array array
|
153
152
|
```
|
154
153
|
|
155
|
-
Bang methods will remove jobs that are not present in given hash/array
|
156
|
-
updates jobs
|
154
|
+
Bang-suffixed methods will remove jobs that are not present in the given hash/array,
|
155
|
+
updates jobs that have the same names, and creates new ones when the names are previously unknown.
|
156
|
+
|
157
157
|
```ruby
|
158
158
|
Sidekiq::Cron::Job#load_from_hash! hash
|
159
159
|
Sidekiq::Cron::Job#load_from_array! array
|
@@ -190,10 +190,10 @@ end
|
|
190
190
|
#return array of all jobs
|
191
191
|
Sidekiq::Cron::Job.all
|
192
192
|
|
193
|
-
#return one job by its
|
193
|
+
#return one job by its unique name - case sensitive
|
194
194
|
Sidekiq::Cron::Job.find "Job Name"
|
195
195
|
|
196
|
-
#return one job by its
|
196
|
+
#return one job by its unique name - you can use hash with 'name' key
|
197
197
|
Sidekiq::Cron::Job.find name: "Job Name"
|
198
198
|
|
199
199
|
#if job can't be found nil is returned
|
@@ -207,7 +207,7 @@ Sidekiq::Cron::Job.destroy_all!
|
|
207
207
|
#destroy job by its name
|
208
208
|
Sidekiq::Cron::Job.destroy "Job Name"
|
209
209
|
|
210
|
-
#destroy
|
210
|
+
#destroy found job
|
211
211
|
Sidekiq::Cron::Job.find('Job name').destroy
|
212
212
|
```
|
213
213
|
|
@@ -230,15 +230,16 @@ job.enque!
|
|
230
230
|
```
|
231
231
|
|
232
232
|
How to start scheduling?
|
233
|
-
Just start
|
233
|
+
Just start Sidekiq workers by running:
|
234
234
|
|
235
235
|
sidekiq
|
236
236
|
|
237
|
-
### Web
|
237
|
+
### Web UI for Cron Jobs
|
238
238
|
|
239
|
-
If you are using
|
239
|
+
If you are using Sidekiq's web UI and you would like to add cron jobs too to this web UI,
|
240
240
|
add `require 'sidekiq/cron/web'` after `require 'sidekiq/web'`.
|
241
|
-
|
241
|
+
|
242
|
+
With this, you will get:
|
242
243
|
![Web UI](https://github.com/ondrejbartas/sidekiq-cron/raw/master/examples/web-cron-ui.png)
|
243
244
|
|
244
245
|
### Forking Processes
|
@@ -248,7 +249,7 @@ before the process forks, causing the following exception
|
|
248
249
|
|
249
250
|
Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
|
250
251
|
|
251
|
-
to occcur. To avoid this, wrap your job creation in the
|
252
|
+
to occcur. To avoid this, wrap your job creation in the call to `Sidekiq.configure_server`:
|
252
253
|
|
253
254
|
```ruby
|
254
255
|
Sidekiq.configure_server do |config|
|
@@ -264,15 +265,28 @@ Note that this API is only available in Sidekiq 3.x.x.
|
|
264
265
|
|
265
266
|
## Under the hood
|
266
267
|
|
267
|
-
When you start
|
268
|
+
When you start the Sidekiq process, it starts one thread with `Sidekiq::Poller` instance, which perform the adding of scheduled jobs to queues, retries etc.
|
268
269
|
|
269
|
-
Sidekiq-Cron
|
270
|
-
if they should be added to queue (their cronline matches time of check).
|
270
|
+
Sidekiq-Cron adds itself into this start procedure and starts another thread with `Sidekiq::Cron::Poller` which checks all enabled Sidekiq cron jobs every 10 seconds, if they should be added to queue (their cronline matches time of check).
|
271
271
|
|
272
272
|
|
273
|
+
## Thanks to
|
274
|
+
* [@7korobi](https://github.com/7korobi)
|
275
|
+
* [@antulik](https://github.com/antulik)
|
276
|
+
* [@felixbuenemann](https://github.com/felixbuenemann)
|
277
|
+
* [@gstark](https://github.com/gstark)
|
278
|
+
* [@RajRoR](https://github.com/RajRoR)
|
279
|
+
* [@romeuhcf](https://github.com/romeuhcf)
|
280
|
+
* [@siruguri](https://github.com/siruguri)
|
281
|
+
* [@Soliah](https://github.com/Soliah)
|
282
|
+
* [@stephankaag](https://github.com/stephankaag)
|
283
|
+
* [@sue445](https://github.com/sue445)
|
284
|
+
* [@sylg](https://github.com/sylg)
|
285
|
+
* [@tmeinlschmidt](https://github.com/tmeinlschmidt)
|
286
|
+
* [@zerobearing2](https://github.com/zerobearing2)
|
273
287
|
|
274
|
-
## Contributing to sidekiq-cron
|
275
288
|
|
289
|
+
## Contributing to sidekiq-cron
|
276
290
|
|
277
291
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
278
292
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
@@ -282,9 +296,6 @@ if they should be added to queue (their cronline matches time of check).
|
|
282
296
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
283
297
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
284
298
|
|
285
|
-
|
286
299
|
## Copyright
|
287
300
|
|
288
|
-
Copyright (c) 2013 Ondrej Bartas. See LICENSE.txt for
|
289
|
-
further details.
|
290
|
-
|
301
|
+
Copyright (c) 2013 Ondrej Bartas. See LICENSE.txt for further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/lib/sidekiq/cron/job.rb
CHANGED
@@ -35,19 +35,24 @@
|
|
35
35
|
<td style="<%= style %>">
|
36
36
|
<% if job.status == 'enabled' %>
|
37
37
|
<form action="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>/enque" method="post">
|
38
|
+
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
38
39
|
<input class='btn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>"/>
|
39
40
|
</form>
|
40
41
|
<form action="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>/disable" method="post">
|
42
|
+
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
41
43
|
<input class='btn btn-xs pull-left' type="submit" name="disable" value="<%= t('Disable') %>"/>
|
42
44
|
</form>
|
43
45
|
<% else %>
|
44
46
|
<form action="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>/enque" method="post">
|
47
|
+
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
45
48
|
<input class='btn btn-xs pull-left' type="submit" name="enque" value="<%= t('EnqueueNow') %>"/>
|
46
49
|
</form>
|
47
50
|
<form action="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>/enable" method="post">
|
51
|
+
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
48
52
|
<input class='btn btn-xs pull-left' type="submit" name="enable" value="<%= t('Enable') %>"/>
|
49
53
|
</form>
|
50
54
|
<form action="<%= root_path %>cron/<%= CGI.escape(job.name).gsub('+', '%20') %>/delete" method="post">
|
55
|
+
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
51
56
|
<input class='btn btn-xs btn-danger pull-left' type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSureDeleteCronJob', :job => job.name) %>"/>
|
52
57
|
</form>
|
53
58
|
<% end %>
|
@@ -32,15 +32,20 @@ header.row
|
|
32
32
|
td[style="#{style}"]
|
33
33
|
-if job.status == 'enabled'
|
34
34
|
form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enque" method="post"
|
35
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
35
36
|
input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueNow')}"
|
36
37
|
form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/disable" method="post"
|
38
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
37
39
|
input.btn.btn-small.pull-left type="submit" name="disable" value="#{t('Disable')}"
|
38
40
|
-else
|
39
41
|
form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enque" method="post"
|
42
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
40
43
|
input.btn.btn-small.pull-left type="submit" name="enque" value="#{t('EnqueueNow')}"
|
41
44
|
form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/enable" method="post"
|
45
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
42
46
|
input.btn.btn-small.pull-left type="submit" name="enable" value="#{t('Enable')}"
|
43
47
|
form action="#{root_path}cron/#{CGI.escape(job.name).gsub('+', '%20')}/delete" method="post"
|
48
|
+
= csrf_tag if respond_to?(:csrf_tag)
|
44
49
|
input.btn.btn-danger.btn-small type="submit" name="delete" value="#{t('Delete')}" data-confirm="#{t('AreYouSureDeleteCronJob', :job => job.name)}"
|
45
50
|
|
46
51
|
- else
|
data/sidekiq-cron.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: sidekiq-cron 0.3.
|
5
|
+
# stub: sidekiq-cron 0.3.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "sidekiq-cron"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Ondrej Bartas"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-08-21"
|
15
15
|
s.description = "Enables to set jobs to be run in specified time (using CRON notation)"
|
16
16
|
s.email = "ondrej@bartas.cz"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -55,7 +55,6 @@ Gem::Specification.new do |s|
|
|
55
55
|
s.specification_version = 4
|
56
56
|
|
57
57
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
-
s.add_runtime_dependency(%q<tilt>, ["< 2.0.0"])
|
59
58
|
s.add_runtime_dependency(%q<sidekiq>, [">= 2.17.3"])
|
60
59
|
s.add_runtime_dependency(%q<rufus-scheduler>, [">= 2.0.24"])
|
61
60
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
@@ -73,7 +72,6 @@ Gem::Specification.new do |s|
|
|
73
72
|
s.add_development_dependency(%q<coveralls>, [">= 0"])
|
74
73
|
s.add_development_dependency(%q<shotgun>, [">= 0"])
|
75
74
|
else
|
76
|
-
s.add_dependency(%q<tilt>, ["< 2.0.0"])
|
77
75
|
s.add_dependency(%q<sidekiq>, [">= 2.17.3"])
|
78
76
|
s.add_dependency(%q<rufus-scheduler>, [">= 2.0.24"])
|
79
77
|
s.add_dependency(%q<bundler>, [">= 0"])
|
@@ -92,7 +90,6 @@ Gem::Specification.new do |s|
|
|
92
90
|
s.add_dependency(%q<shotgun>, [">= 0"])
|
93
91
|
end
|
94
92
|
else
|
95
|
-
s.add_dependency(%q<tilt>, ["< 2.0.0"])
|
96
93
|
s.add_dependency(%q<sidekiq>, [">= 2.17.3"])
|
97
94
|
s.add_dependency(%q<rufus-scheduler>, [">= 2.0.24"])
|
98
95
|
s.add_dependency(%q<bundler>, [">= 0"])
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-cron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondrej Bartas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: tilt
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "<"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "<"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.0
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: sidekiq
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|