sidekiq-cron 1.3.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '091abb12b81574bf5fad5130f4e343aaad6adeceb0daae8c46a6d09dbaa7ee58'
4
- data.tar.gz: 1ecbf9ba2fd82ff69a423993e7aa3678e7fabc6fb55e2acea74ec1cb83a8af3d
3
+ metadata.gz: 2d138bcaa8a86a88e84e5cd8b5b9188e68217e268a466aef03f2b5dd30a7226d
4
+ data.tar.gz: 8cae5daa6693161b48b71b40607a0c8182764a82ffc3efd5eb8fd7bd0df65da7
5
5
  SHA512:
6
- metadata.gz: 9cfd9a8e2efdcf3ae293533421a1c09b7dcc3154e90d749fd3e3a47ccaff6d673daa68877b2ca3b7939139603ee04e816c8c5ae51ef64d818d8d013eff43d9f0
7
- data.tar.gz: 0d86e3bb4b06869889934a37ef30f117a4a28769a07e75b3d7547c49d9d8e5dfe4931f608b8b7b18cdc1b70cfdaf6be55aa043844b047b877ff7dfa21271a9f4
6
+ metadata.gz: 0dd9f32211d51bbd71fadbd36b30970193fc725408207fe255ff58f88b56dc484815a0f52c788acebbcc6230665cf7c02ccdbd4f7425dd4d9414cd8dd098dbf7
7
+ data.tar.gz: 73e8040c64d5de227d0077a1d95081d47140ec0481706b16c00e830f421ce8952f0fb48a991f71033c65a115dc0f29f06e2a6c56aae38565ed5dae6bfcaea14d
data/Changes.md CHANGED
@@ -1,11 +1,33 @@
1
- v 1.3.0
2
- -------
3
-
4
- - add confirmation dialog when enquing jobs from UI
5
- - start to support Sidekiq `average_scheduled_poll_interval` option (replaced `poll_interval`)
6
- - enable to use latest fugit to parse cron notation alowing use of natural language (ie `"every 30 minutes"`)
7
- - fix deprecation warning for redis 4.6.x
8
- - fix different response from Redis#exists in different redis versions
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## 1.5.1
6
+
7
+ - Fixes an issue that prevented the gem to work in previous Sidekiq versions (https://github.com/ondrejbartas/sidekiq-cron/pull/335)
8
+
9
+ ## 1.5.0
10
+
11
+ - Integrate Sidekiq v6.5 breaking changes (https://github.com/ondrejbartas/sidekiq-cron/pull/331)
12
+ - Add portuguese translations (https://github.com/ondrejbartas/sidekiq-cron/pull/332)
13
+
14
+ ## 1.4.0
15
+
16
+ - Fix buttons order in job show view (https://github.com/ondrejbartas/sidekiq-cron/pull/302)
17
+ - Dark Mode support in UI (https://github.com/ondrejbartas/sidekiq-cron/pull/317/282)
18
+ - Remove invocation of deprecated Redis functionality (https://github.com/ondrejbartas/sidekiq-cron/pull/318)
19
+ - Internal code cleanup (https://github.com/ondrejbartas/sidekiq-cron/pull/317)
20
+ - Optimize gem size (https://github.com/ondrejbartas/sidekiq-cron/pull/322)
21
+ - Fix "Show All" button on cron jobs view with Sidekiq 6.3.0+ (https://github.com/ondrejbartas/sidekiq-cron/pull/321)
22
+ - Documentation updates
23
+
24
+ ## 1.3.0
25
+
26
+ - Add confirmation dialog when enquing jobs from UI
27
+ - Start to support Sidekiq `average_scheduled_poll_interval` option (replaced `poll_interval`)
28
+ - Enable to use latest fugit to parse cron notation alowing use of natural language (ie `"every 30 minutes"`)
29
+ - Fix deprecation warning for Redis 4.6.x
30
+ - Fix different response from Redis#exists in different Redis versions
9
31
  - All PRs:
10
32
  - https://github.com/ondrejbartas/sidekiq-cron/pull/275
11
33
  - https://github.com/ondrejbartas/sidekiq-cron/pull/287
@@ -14,85 +36,76 @@ v 1.3.0
14
36
  - https://github.com/ondrejbartas/sidekiq-cron/pull/314
15
37
  - https://github.com/ondrejbartas/sidekiq-cron/pull/288
16
38
 
17
- v 1.2.0
18
- -------
19
-
20
- - updated readme
21
- - fix problem with Sidekiq::Launcher and requiring it when not needed
22
- - better patching of Sidekiq::Launcher
23
- - fixed Dockerfile
24
-
25
- v 1.1.0
26
- -------
27
-
28
- - updated readme
29
- - fix unit tests - changed argument error when getting invalid cron format
30
- - when fallbacking old job enqueued time use `Time.parse` šwithout format (so ruby can decide best method to parse it)
31
- - add option `date_as_argument` which will add to your job arguments on last place `Time.now.to_f` when it was eneuqued
32
- - add option `description` which will allow you to add notes to your jobs so in web view you can see it
33
- - fixed translations
34
-
35
- v 1.0.4
36
- -------
37
-
38
- - fix problem with upgrading to 1.0.x - parsing last enqued time didn't count with old time format stored in redis
39
-
40
- v 1.0.0
41
- -------
42
-
43
- - use [fugit](https://github.com/floraison/fugit) instead of [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) - API of cron didn't change (rufus scheduler is using fugit)
44
- - better working with Timezones
45
- - translations for JA, zh-CN
46
- - cron without timezone are considered as UTC, to add Timezone to cron use format `* * * * * Europe/Berlin`
47
- - be aware that this release can change when your jobs are enqueued (for me it didn't change but it is in one project, in other it can shift by different timezone setup)
48
-
49
- v 0.6.0
50
- -------
51
-
52
- - set poller to check jobs every 30s by default (possible to override by `Sidekiq.options[:poll_interval] = 10`)
53
- - add group actions (enqueue, enable, disable, delete) all in web view
54
- - fix poller to enqueu all jobs in poll start time
55
- - add performance test for enqueue of jobs (10 000 jobs in less than 19s)
56
- - fix problem with default queue
57
- - remove redis-namespace from dependencies
58
- - update ruby versions in travis
59
-
60
- v 0.5.0
61
- -------
62
- - add docker support
63
- - all crons are now evaluated in UTC
64
- - fix rufus scheduler & timezones problems
65
- - add support for sidekiq 4.2.1
66
- - fix readme
67
- - add Russian locale
68
- - user Rack.env in tests
69
- - faster enque of jobs
70
- - permit to use ActiveJob::Base.queue_name_delimiter
71
- - fix problem with multiple times enque #84
72
- - fix problem with enque of unknown class
73
-
74
- v 0.4.0
75
- -------
76
-
77
- - enable to work with sidekiq >= 4.0.0
78
- - fix readme
79
-
80
- v 0.3.1
81
- -------
82
-
83
- - add CSRF tags to forms so it will work with sidekiq >= 3.4.2
84
- - remove tilt dependency
85
-
86
- v 0.3.0
87
- -------
88
-
89
- - suport for Active Job
90
- - sidekiq cron web ui needs to be loaded by: require 'sidekiq/cron/web'
91
- - add load_from_hash! and load_from_array! which cleanup jobs before adding new ones
92
-
93
- v 0.1.1
94
- -------
95
-
96
- - add Web fontend with enabled/disable job, unqueue now, delete job
97
- - add cron poller - enqueu cro jobs
98
- - add cron job - save all needed data to redis
39
+ ## 1.2.0
40
+
41
+ - Updated readme
42
+ - Fix problem with Sidekiq::Launcher and requiring it when not needed
43
+ - Better patching of Sidekiq::Launcher
44
+ - Fixed Dockerfile
45
+
46
+ ## 1.1.0
47
+
48
+ - Updated readme
49
+ - Fix unit tests - changed argument error when getting invalid cron format
50
+ - When fallbacking old job enqueued time use `Time.parse` without format (so ruby can decide best method to parse it)
51
+ - Add option `date_as_argument` which will add to your job arguments on last place `Time.now.to_f` when it was eneuqued
52
+ - Add option `description` which will allow you to add notes to your jobs so in web view you can see it
53
+ - Fixed translations
54
+
55
+ ## 1.0.4
56
+
57
+ - Fix problem with upgrading to 1.0.x - parsing last enqued time didn't count with old time format stored in Redis
58
+
59
+ ## 1.0.0
60
+
61
+ - Use [fugit](https://github.com/floraison/fugit) instead of [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) - API of cron didn't change (rufus scheduler is using fugit)
62
+ - Better working with Timezones
63
+ - Translations for JA, zh-CN
64
+ - Cron without timezone are considered as UTC, to add Timezone to cron use format `* * * * * Europe/Berlin`
65
+ - Be aware that this release can change when your jobs are enqueued (for me it didn't change but it is in one project, in other it can shift by different timezone setup)
66
+
67
+ ## 0.6.0
68
+
69
+ - Set poller to check jobs every 30s by default (possible to override by `Sidekiq.options[:poll_interval] = 10`)
70
+ - Add group actions (enqueue, enable, disable, delete) all in web view
71
+ - Fix poller to enqueu all jobs in poll start time
72
+ - Add performance test for enqueue of jobs (10 000 jobs in less than 19s)
73
+ - Fix problem with default queue
74
+ - Remove redis-namespace from dependencies
75
+ - Update ruby versions in travis
76
+
77
+ ## 0.5.0
78
+
79
+ - Add Docker support
80
+ - All crons are now evaluated in UTC
81
+ - Fix rufus scheduler & timezones problems
82
+ - Add support for Sidekiq 4.2.1
83
+ - Fix readme
84
+ - Add Russian locale
85
+ - User Rack.env in tests
86
+ - Faster enqueue of jobs
87
+ - Permit to use ActiveJob::Base.queue_name_delimiter
88
+ - Fix problem with multiple times enqueue #84
89
+ - Fix problem with enqueue of unknown class
90
+
91
+ ## 0.4.0
92
+
93
+ - Enable to work with Sidekiq >= 4.0.0
94
+ - Fix readme
95
+
96
+ ## 0.3.1
97
+
98
+ - Add CSRF tags to forms so it will work with Sidekiq >= 3.4.2
99
+ - Remove Tilt dependency
100
+
101
+ ## 0.3.0
102
+
103
+ - Suport for Active Job
104
+ - Sidekiq cron web ui needs to be loaded by: require 'sidekiq/cron/web'
105
+ - Add load_from_hash! and load_from_array! which cleanup jobs before adding new ones
106
+
107
+ ## 0.1.1
108
+
109
+ - Add Web front-end with enabled/disable job, enqueue now, delete job
110
+ - Add cron poller - enqueue cron jobs
111
+ - Add cron job - save all needed data to Redis
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Sidekiq-Cron
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/sidekiq-cron.svg)](http://badge.fury.io/rb/sidekiq-cron)
3
+ [![Gem Version](https://badge.fury.io/rb/sidekiq-cron.svg)](https://badge.fury.io/rb/sidekiq-cron)
4
4
  [![Build Status](https://github.com/ondrejbartas/sidekiq-cron/workflows/CI/badge.svg?branch=master)](https://github.com/ondrejbartas/sidekiq-cron/actions)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/ondrejbartas/sidekiq-cron/badge.svg?branch=master)](https://coveralls.io/github/ondrejbartas/sidekiq-cron?branch=master)
6
6
  [![Join the chat at https://gitter.im/ondrejbartas/sidekiq-cron](https://badges.gitter.im/ondrejbartas/sidekiq-cron.svg)](https://gitter.im/ondrejbartas/sidekiq-cron?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
7
7
 
8
- > A scheduling add-on for [Sidekiq](http://sidekiq.org)
8
+ > A scheduling add-on for [Sidekiq](https://sidekiq.org/)
9
9
 
10
10
  🎬 [Introduction video about Sidekiq-Cron by Drifting Ruby](https://www.driftingruby.com/episodes/periodic-tasks-with-sidekiq-cron)
11
11
 
12
- Sidekiq-Cron runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` parsed by [Fugit](https://github.com/floraison/fugit), more about [cron notation](http://www.nncron.ru/help/EN/working/cron-format.htm).
12
+ Sidekiq-Cron runs a thread alongside Sidekiq workers to schedule jobs at specified times (using cron notation `* * * * *` parsed by [Fugit](https://github.com/floraison/fugit)).
13
13
 
14
14
  Checks for new jobs to schedule every 30 seconds and doesn't schedule the same job multiple times when more than one Sidekiq worker is running.
15
15
 
@@ -21,65 +21,83 @@ Works with ActiveJob (Rails 4.2+).
21
21
 
22
22
  You don't need Sidekiq PRO, you can use this gem with plain Sidekiq.
23
23
 
24
- ## Upgrade from <0.6x to 1.0.x
24
+ ## Upgrade from < 0.6 to 1.0
25
25
 
26
- Please be aware that Sidekiq-Cron < 1.0 was relying on rufus-scheduler < 3.5. Using those older sidekiq-cron with rufus-scheduler >= 3.5 ends up with jobs failing on creation. Sidekiq-cron 1.0 includes a patch that switches from rufus-scheduler to rufus-scheduler's core dependency, fugit.
26
+ Please be aware that Sidekiq-Cron < 1.0 was relying on rufus-scheduler < 3.5. Using those older versions with rufus-scheduler >= 3.5 ends up with jobs failing on creation. Sidekiq-Cron 1.0 includes a patch that switches from rufus-scheduler to rufus-scheduler's core dependency, fugit.
27
27
 
28
28
  ## Changelog
29
29
 
30
- Before upgrading to new version, please read our [ChangeLog](Changes.md).
30
+ Before upgrading to a new version, please read our [Changelog](Changes.md).
31
31
 
32
32
  ## Installation
33
33
 
34
34
  ### Requirements
35
35
 
36
- - Redis 2.8 or greater is required. (Redis 3.0.3 or greater is recommended for large scale use)
37
- - Sidekiq 5, or 4, or 3 and greater is required (for Sidekiq < 4 use version sidekiq-cron 0.3.1)
36
+ - Redis 2.8 or greater is required (Redis 3.0.3 or greater is recommended for large scale use)
37
+ - Sidekiq 4.2 or greater is required (for Sidekiq < 4 use version sidekiq-cron 0.3.1)
38
+ - Sidekiq 6.5 requires Sidekiq-Cron 1.5+
38
39
 
39
40
  Install the gem:
40
41
 
41
- $ gem install sidekiq-cron
42
+ ```
43
+ $ gem install sidekiq-cron
44
+ ```
42
45
 
43
46
  Or add to your `Gemfile` and run `bundle install`:
44
47
 
45
- gem "sidekiq-cron", "~> 1.1"
48
+ ```ruby
49
+ gem "sidekiq-cron"
50
+ ```
46
51
 
47
- ## Getting Started
52
+ **NOTE** If you are not using Rails, you need to add `require 'sidekiq-cron'` somewhere after `require 'sidekiq'`.
48
53
 
49
- If you are not using Rails, you need to add `require 'sidekiq-cron'` somewhere after `require 'sidekiq'`.
54
+ ## Getting Started
50
55
 
51
56
  **Job properties:**
52
57
 
53
58
  ```ruby
54
59
  {
55
- 'name' => 'name_of_job', # must be uniq!
56
- 'cron' => '1 * * * *', # execute at 1 minute of every hour, ex: 12:01, 13:01, 14:01, 15:01, ... (HH:MM)
57
- 'class' => 'MyClass',
58
- # OPTIONAL
59
- 'queue' => 'name of queue',
60
- 'args' => '[Array or Hash] of arguments which will be passed to perform method',
61
- 'date_as_argument' => true, # add the time of execution as last argument of the perform method
62
- 'active_job' => true, # enqueue job through rails 4.2+ active job interface
63
- 'queue_name_prefix' => 'prefix', # rails 4.2+ active job queue with prefix
64
- 'queue_name_delimiter' => '.', # rails 4.2+ active job queue with custom delimiter
65
- 'description' => 'A sentence describing what work this job performs.'
60
+ 'name' => 'name_of_job', # must be uniq!
61
+ 'cron' => '1 * * * *', # execute at 1 minute of every hour, ex: 12:01, 13:01, 14:01, 15:01, ... (HH:MM)
62
+ 'class' => 'MyClass',
63
+ # OPTIONAL
64
+ 'queue' => 'name of queue',
65
+ 'args' => '[Array or Hash] of arguments which will be passed to perform method',
66
+ 'date_as_argument' => true, # add the time of execution as last argument of the perform method
67
+ 'active_job' => true, # enqueue job through rails 4.2+ active job interface
68
+ 'queue_name_prefix' => 'prefix', # rails 4.2+ active job queue with prefix
69
+ 'queue_name_delimiter' => '.', # rails 4.2+ active job queue with custom delimiter
70
+ 'description' => 'A sentence describing what work this job performs.'
71
+ 'status' => 'disabled' # default: enabled
66
72
  }
67
73
  ```
68
74
 
69
- ### Time, cron and sidekiq-cron
75
+ ### Time, cron and Sidekiq-Cron
70
76
 
71
77
  For testing your cron notation you can use [crontab.guru](https://crontab.guru).
72
78
 
73
- Sidekiq-Cron uses [Fugit](https://github.com/floraison/fugit) to parse the cronline.
79
+ Sidekiq-Cron uses [Fugit](https://github.com/floraison/fugit) to parse the cronline. So please, check Fugit documentation for further information about allowed formats.
74
80
 
75
81
  If using Rails, this is evaluated against the timezone configured in Rails, otherwise the default is UTC.
76
82
 
77
83
  If you want to have your jobs enqueued based on a different time zone you can specify a timezone in the cronline,
78
84
  like this `'0 22 * * 1-5 America/Chicago'`.
79
85
 
80
- See [rufus-scheduler documentation](https://github.com/jmettraux/rufus-scheduler#a-note-about-timezones) for more information.
86
+ #### Second-precision (sub-minute) cronlines
87
+
88
+ In addition to the standard 5-parameter cronline format, sidekiq-cron supports scheduling jobs with second-precision using a modified 6-parameter cronline format:
89
+
90
+ `Seconds Minutes Hours Days Months DayOfWeek`
81
91
 
82
- **NOTE** Rufus scheduler is using Fugit under the hood, so documentation for Rufus Scheduler can help you also.
92
+ For example: `"*/30 * * * * *"` would schedule a job to run every 30 seconds.
93
+
94
+ Note that if you plan to schedule jobs with second precision you may need to override the default schedule poll interval so it is lower than the interval of your jobs:
95
+
96
+ ```ruby
97
+ Sidekiq.options[:average_scheduled_poll_interval] = 10
98
+ ```
99
+
100
+ The default value at time of writing is 30 seconds. See [under the hood](#under-the-hood) for more details.
83
101
 
84
102
  ### What objects/classes can be scheduled
85
103
 
@@ -114,7 +132,7 @@ end
114
132
  For Active jobs you can use `symbolize_args: true` in `Sidekiq::Cron::Job.create` or in Hash configuration,
115
133
  which will ensure that arguments you are passing to it will be symbolized when passed back to `perform` method in worker.
116
134
 
117
- #### Adding Cron job:
135
+ #### Adding Cron job
118
136
 
119
137
  ```ruby
120
138
  class HardWorker
@@ -187,8 +205,8 @@ Sidekiq::Cron::Job.load_from_array array
187
205
  Bang-suffixed methods will remove jobs that are not present in the given hash/array, update jobs that have the same names, and create new ones when the names are previously unknown.
188
206
 
189
207
  ```ruby
190
- Sidekiq::Cron::Job#load_from_hash! hash
191
- Sidekiq::Cron::Job#load_from_array! array
208
+ Sidekiq::Cron::Job.load_from_hash! hash
209
+ Sidekiq::Cron::Job.load_from_array! array
192
210
  ```
193
211
 
194
212
  Or from YAML (same notation as Resque-scheduler):
@@ -218,6 +236,20 @@ if File.exist?(schedule_file) && Sidekiq.server?
218
236
  end
219
237
  ```
220
238
 
239
+ From version 3.x it is better not to use separate initializer of schedule instead add `config.on(:startup)` to your Sidekiq configuration:
240
+
241
+ ```ruby
242
+ Sidekiq.configure_server do |config|
243
+ config.on(:startup) do
244
+ schedule_file = "config/schedule.yml"
245
+
246
+ if File.exist?(schedule_file)
247
+ Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
248
+ end
249
+ end
250
+ end
251
+ ```
252
+
221
253
  Or you can use for loading jobs from yml file [sidekiq-cron-tasks](https://github.com/coverhound/sidekiq-cron-tasks) which will add rake task `bundle exec rake sidekiq_cron:load` to your rails application.
222
254
 
223
255
  ### Finding jobs
@@ -235,7 +267,7 @@ Sidekiq::Cron::Job.find name: "Job Name"
235
267
  # if job can't be found nil is returned
236
268
  ```
237
269
 
238
- ### Destroy jobs:
270
+ ### Destroy jobs
239
271
 
240
272
  ```ruby
241
273
  # destroy all jobs
@@ -248,7 +280,7 @@ Sidekiq::Cron::Job.destroy "Job Name"
248
280
  Sidekiq::Cron::Job.find('Job name').destroy
249
281
  ```
250
282
 
251
- ### Work with job:
283
+ ### Work with job
252
284
 
253
285
  ```ruby
254
286
  job = Sidekiq::Cron::Job.find('Job name')
@@ -271,7 +303,9 @@ job.enque!
271
303
 
272
304
  Just start Sidekiq workers by running:
273
305
 
274
- $ sidekiq
306
+ ```
307
+ $ sidekiq
308
+ ```
275
309
 
276
310
  ### Web UI for Cron Jobs
277
311
 
@@ -279,33 +313,34 @@ If you are using Sidekiq's web UI and you would like to add cron jobs too to thi
279
313
  add `require 'sidekiq/cron/web'` after `require 'sidekiq/web'`.
280
314
 
281
315
  With this, you will get:
282
- ![Web UI](https://github.com/ondrejbartas/sidekiq-cron/raw/master/examples/web-cron-ui.png)
283
316
 
284
- ### Forking Processes
317
+ ![Web UI](examples/web-cron-ui.png)
318
+
319
+ ### Forking Processes or problem with `NotImplementedError`
285
320
 
286
321
  If you're using a forking web server like Unicorn you may run into an issue where the Redis connection is used
287
- before the process forks, causing the following exception:
322
+ before the process forks, causing the following exception to occur:
288
323
 
289
- Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
324
+ ```
325
+ Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.
326
+ ```
290
327
 
291
- to occur. To avoid this, wrap your job creation in the call to `Sidekiq.configure_server`:
328
+ To avoid this, wrap your job creation in the call to `Sidekiq.configure_server`:
292
329
 
293
330
  ```ruby
294
331
  Sidekiq.configure_server do |config|
295
- schedule_file = "config/schedule.yml"
332
+ config.on(:startup) do
333
+ schedule_file = "config/schedule.yml"
296
334
 
297
- if File.exist?(schedule_file)
298
- Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
335
+ if File.exist?(schedule_file)
336
+ Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
337
+ end
299
338
  end
300
339
  end
301
340
  ```
302
341
 
303
342
  **NOTE** This API is only available in Sidekiq 3.x.
304
343
 
305
- ## Tests in Sidekiq-Cron
306
-
307
- If you need to check code of sidekiq-cron run `rake test` in this repository.
308
-
309
344
  ## Under the hood
310
345
 
311
346
  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.
@@ -315,95 +350,31 @@ Sidekiq-Cron adds itself into this start procedure and starts another thread wit
315
350
  Sidekiq-Cron is checking jobs to be enqueued every 30s by default, you can change it by setting:
316
351
 
317
352
  ```ruby
318
- # For Sidekiq >= 3.4
319
353
  Sidekiq.options[:average_scheduled_poll_interval] = 10
320
-
321
- # For older versions of Sidekiq
322
- Sidekiq.options[:poll_interval] = 10
323
354
  ```
324
355
 
325
- Sidekiq-Cron is safe to use with multiple sidekiq processes or nodes. It uses a Redis sorted set to determine that only the first process who asks can enqueue scheduled jobs into the queue.
326
-
327
- ## Thanks to
328
- * [@284km](https://github.com/284km)
329
- * [@7korobi](https://github.com/7korobi)
330
- * [@adrianobarroso](https://github.com/adrianobarroso])
331
- * [@alexeyramazanov](https://github.com/alexeyramazanov)
332
- * [@antulik](https://github.com/antulik)
333
- * [@arthurbryant](https://github.com/arthurbryant)
334
- * [@cabello](https://github.com/cabello)
335
- * [@camkidman](https://github.com/camkidman)
336
- * [@cgunther](https://github.com/cgunther)
337
- * [@chuchuva](https://github.com/chuchuva)
338
- * [@corroded](https://github.com/corroded)
339
- * [@D1ceWard](https://github.com/D1ceWard])
340
- * [@davidtrogers](https://github.com/davidtrogers)
341
- * [@denispeplin](https://github.com/denispeplin)
342
- * [@dwarburt](https://github.com/dwarburt)
343
- * [@Envek](https://github.com/Envek)
344
- * [@Eunix](https://github.com/Eunix)
345
- * [@felixbuenemann](https://github.com/felixbuenemann)
346
- * [@film42](https://github.com/film42])
347
- * [@giriss](https://github.com/giriss)
348
- * [@gitter](https://github.com/gitter)
349
- * [@gstark](https://github.com/gstark)
350
- * [@h0jeZvgoxFepBQ2C](https://github.com/h0jeZvgoxFepBQ2C)
351
- * [@incubus](https://github.com/incubus)
352
- * [@jack0pan](https://github.com/jack0pan)
353
- * [@jmettraux](https://github.com/jmettraux)
354
- * [@johnathanludwig](https://github.com/johnathanludwig)
355
- * [@joshuacronemeyer](https://github.com/joshuacronemeyer)
356
- * [@jpserra](https://github.com/jpserra)
357
- * [@Junyulive](https://github.com/Junyulive)
358
- * [@le0pard](https://github.com/le0pard)
359
- * [@lepfhty](https://github.com/lepfhty)
360
- * [@macool](https://github.com/macool)
361
- * [@masayukioguni](https://github.com/masayukioguni)
362
- * [@matsimitsu](https://github.com/matsimitsu)
363
- * [@merrington](https://github.com/merrington)
364
- * [@MikeRogers0](https://github.com/MikeRogers0)
365
- * [@MMartyn](https://github.com/MMartyn)
366
- * [@mrchucho](https://github.com/mrchucho)
367
- * [@n00dle](https://github.com/n00dle)
368
- * [@ngouy](https://github.com/ngouy)
369
- * [@nhoffmann](https://github.com/nhoffmann)
370
- * [@nicolasleger](https://github.com/nicolasleger)
371
- * [@nikolai-b](https://github.com/nikolai-b)
372
- * [@oivoodoo](https://github.com/oivoodoo)
373
- * [@paniko0](https://github.com/paniko0)
374
- * [@petergoldstein](https://github.com/petergoldstein)
375
- * [@RajRoR](https://github.com/RajRoR)
376
- * [@rmm5t](https://github.com/rmm5t)
377
- * [@romeuhcf](https://github.com/romeuhcf)
378
- * [@rylwin](https://github.com/rylwin)
379
- * [@ryohashimoto](https://github.com/ryohashimoto)
380
- * [@safeforge](https://github.com/safeforge)
381
- * [@siruguri](https://github.com/siruguri)
382
- * [@Soliah](https://github.com/Soliah)
383
- * [@spk](https://github.com/spk)
384
- * [@stephankaag](https://github.com/stephankaag)
385
- * [@stormsilver](https://github.com/stormsilver)
386
- * [@sue445](https://github.com/sue445)
387
- * [@sylg](https://github.com/sylg)
388
- * [@tai2](https://github.com/tai2)
389
- * [@tfluehmann](https://github.com/tfluehmann)
390
- * [@timminkov](https://github.com/timminkov)
391
- * [@tisba](https://github.com/tisba)
392
- * [@tmeinlschmidt](https://github.com/tmeinlschmidt)
393
- * [@tomprats](https://github.com/tomprats)
394
- * [@zedtux](https://github.com/zedtux)
395
- * [@zerobearing2](https://github.com/zerobearing2)
396
-
397
- ## Contributing to sidekiq-cron
356
+ Sidekiq-Cron is safe to use with multiple Sidekiq processes or nodes. It uses a Redis sorted set to determine that only the first process who asks can enqueue scheduled jobs into the queue.
357
+
358
+ ## Contributing
359
+
360
+ **Thanks to all [contributors](https://github.com/ondrejbartas/sidekiq-cron/graphs/contributors), you’re awesome and this wouldn’t be possible without you!**
398
361
 
399
362
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
400
363
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
401
364
  * Fork the project.
402
365
  * Start a feature/bugfix branch.
403
366
  * Commit and push until you are happy with your contribution.
404
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
405
- * 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.
367
+ * Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
368
+ * Open a pull request!
369
+
370
+ ### Testing
371
+
372
+ You can execute the test suite by running:
373
+
374
+ ```
375
+ $ bundle exec rake test
376
+ ```
406
377
 
407
- ## Copyright
378
+ ## License
408
379
 
409
380
  Copyright (c) 2013 Ondrej Bartas. See [LICENSE](LICENSE.txt) for further details.
data/Rakefile CHANGED
@@ -1,25 +1,10 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
- require 'bundler/setup'
5
- require 'bundler'
6
-
7
- begin
8
- Bundler.setup(:default, :development)
9
- rescue Bundler::BundlerError => e
10
- $stderr.puts e.message
11
- $stderr.puts "Run `bundle install` to install missing gems"
12
- exit e.status_code
13
- end
14
- require 'rake'
15
-
16
- #TESTING
17
-
1
+ require 'bundler/gem_tasks'
18
2
  require 'rake/testtask'
3
+
19
4
  task :default => :test
20
5
 
21
6
  Rake::TestTask.new(:test) do |t|
22
- t.test_files = FileList['test/functional/**/*_test.rb', 'test/unit/**/*_test.rb','test/integration/**/*_test.rb']
7
+ t.test_files = FileList['test/unit/**/*_test.rb', 'test/integration/**/*_test.rb']
23
8
  t.warning = false
24
9
  t.verbose = false
25
10
  end
@@ -31,12 +16,6 @@ namespace :test do
31
16
  t.verbose = false
32
17
  end
33
18
 
34
- Rake::TestTask.new(:functional) do |t|
35
- t.test_files = FileList['test/functional/**/*_test.rb']
36
- t.warning = false
37
- t.verbose = false
38
- end
39
-
40
19
  Rake::TestTask.new(:integration) do |t|
41
20
  t.test_files = FileList['test/integration/**/*_test.rb']
42
21
  t.warning = false
@@ -1,15 +1,10 @@
1
1
  require 'fugit'
2
2
  require 'sidekiq'
3
- require 'sidekiq/util'
4
3
  require 'sidekiq/cron/support'
5
4
 
6
5
  module Sidekiq
7
6
  module Cron
8
-
9
7
  class Job
10
- include Util
11
- extend Util
12
-
13
8
  #how long we would like to store informations about previous enqueues
14
9
  REMEMBER_THRESHOLD = 24 * 60 * 60
15
10
  LAST_ENQUEUE_TIME_FORMAT = '%Y-%m-%d %H:%M:%S %z'
@@ -76,7 +71,7 @@ module Sidekiq
76
71
 
77
72
  save_last_enqueue_time
78
73
  add_jid_history jid
79
- logger.debug { "enqueued #{@name}: #{@message}" }
74
+ Sidekiq.logger.debug { "enqueued #{@name}: #{@message}" }
80
75
  end
81
76
 
82
77
  def is_active_job?
@@ -468,7 +463,7 @@ module Sidekiq
468
463
  time = Time.now.utc
469
464
  conn.zadd(job_enqueued_key, time.to_f.to_s, formated_last_time(time).to_s) unless conn.public_send(REDIS_EXISTS_METHOD, job_enqueued_key)
470
465
  end
471
- logger.info { "Cron Jobs - add job with name: #{@name}" }
466
+ Sidekiq.logger.info { "Cron Jobs - added job with name: #{@name}" }
472
467
  end
473
468
 
474
469
  def save_last_enqueue_time
@@ -509,7 +504,7 @@ module Sidekiq
509
504
  #delete main job
510
505
  conn.del redis_key
511
506
  end
512
- logger.info { "Cron Jobs - deleted job with name: #{@name}" }
507
+ Sidekiq.logger.info { "Cron Jobs - deleted job with name: #{@name}" }
513
508
  end
514
509
 
515
510
  # remove all job from cron
@@ -517,7 +512,7 @@ module Sidekiq
517
512
  all.each do |job|
518
513
  job.destroy
519
514
  end
520
- logger.info { "Cron Jobs - deleted all jobs" }
515
+ Sidekiq.logger.info { "Cron Jobs - deleted all jobs" }
521
516
  end
522
517
 
523
518
  # remove "removed jobs" between current jobs and new jobs