resque-scheduler 4.3.1 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of resque-scheduler might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 52d400f5dbdd7e1d642466e7999f6ec7f6805355
4
- data.tar.gz: 7caa30cc7095a5451f915a981b64cd0dda7149e5
2
+ SHA256:
3
+ metadata.gz: cf266ccd935c9464051349f32169248c7fab52aa84304a98f0d05e5e91ccec22
4
+ data.tar.gz: 517e84a33953fa3bf695ae26f23912d436fc86b7dc0ac9502fb09ca1cc02f1c3
5
5
  SHA512:
6
- metadata.gz: 20630b816c225504beb88315ef1df2fa1672e44e05c6386446c53e6b5422ab7b1cf478775f6660e7f880a73771f073746fb0853258a5ad71f450b51e15290ce2
7
- data.tar.gz: 8fa83bedc4ffd9759d5390ad19ce82b8188445df3aa5c46ac2a32dc8a162e66c69c73f4599ad90ea4a3eb2191661fe82ece5aea30bd834d3e9e8495267e84a7b
6
+ metadata.gz: 91b8916a16ad2a6a20860001f137fb558d6dbfa7aca3c67abb022acc298a3f2afac7c1527a043b2d5ed3fa582d0203cc988b101cc45819ae3832145328cdea7d
7
+ data.tar.gz: 90669eb2a75e71612b1505c87a6ed704e70b80b34aa89023ce84e8a256c1d3e0e4eb2a7931c8e480ff99524ed489bb97ed2d98f512f6646f19d50751613ac97c
@@ -0,0 +1,12 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+
9
+ - package-ecosystem: "bundler"
10
+ directory: "/"
11
+ schedule:
12
+ interval: "weekly"
@@ -0,0 +1,4 @@
1
+ # Docs for this file can be found here:
2
+ # https://docs.github.com/en/github/administering-a-repository/displaying-a-sponsor-button-in-your-repository
3
+
4
+ github: ["iloveitaly"]
@@ -0,0 +1,59 @@
1
+ name: "CodeQL"
2
+
3
+ on:
4
+ push:
5
+ branches: [ master, '*-stable' ]
6
+ pull_request:
7
+ # The branches below must be a subset of the branches above
8
+ branches: [ master ]
9
+ schedule:
10
+ - cron: '44 16 * * 6'
11
+
12
+ jobs:
13
+ analyze:
14
+ name: Analyze
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ actions: read
18
+ contents: read
19
+ security-events: write
20
+
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ language: [ 'ruby' ]
25
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
26
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
27
+
28
+ steps:
29
+ - name: Checkout repository
30
+ uses: actions/checkout@v3
31
+
32
+ # Initializes the CodeQL tools for scanning.
33
+ - name: Initialize CodeQL
34
+ uses: github/codeql-action/init@v2
35
+ with:
36
+ languages: ${{ matrix.language }}
37
+ # If you wish to specify custom queries, you can do so here or in a config file.
38
+ # By default, queries listed here will override any specified in a config file.
39
+ # Prefix the list here with "+" to use these queries and those in the config file.
40
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
41
+
42
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
43
+ # If this step fails, then you should remove it and run the build manually (see below)
44
+ - name: Autobuild
45
+ uses: github/codeql-action/autobuild@v2
46
+
47
+ # ℹ️ Command-line programs to run using the OS shell.
48
+ # 📚 https://git.io/JvXDl
49
+
50
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
51
+ # and modify them (or add more) to build your code if your project
52
+ # uses a compiled language
53
+
54
+ #- run: |
55
+ # make bootstrap
56
+ # make release
57
+
58
+ - name: Perform CodeQL Analysis
59
+ uses: github/codeql-action/analyze@v2
@@ -0,0 +1,27 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ rubocop:
11
+ name: Rubocop
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ matrix:
15
+ os: [ubuntu-latest]
16
+ ruby: [
17
+ 2.4
18
+ ]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: Ruby linter
27
+ run: bundle exec rubocop
@@ -0,0 +1,66 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ continue-on-error: true
12
+ runs-on: ubuntu-latest
13
+ services:
14
+ redis:
15
+ image: redis
16
+ ports:
17
+ - 6379:6379
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby-version:
22
+ - 2.3
23
+ - 2.4
24
+ - 2.5
25
+ - 2.6
26
+ - 2.7
27
+ - "3.0"
28
+ - 3.1
29
+ resque-version:
30
+ - "master"
31
+ - "~> 2.2.0"
32
+ - "~> 1.27"
33
+ rufus-scheduler:
34
+ - "3.2"
35
+ - "3.4"
36
+ - "3.5"
37
+ - "3.6"
38
+ exclude:
39
+ - ruby-version: head
40
+ rufus-scheduler: 3.2
41
+
42
+ - ruby-version: 2.3
43
+ resque-version: 1.27
44
+ rufus-scheduler: 3.4
45
+ - ruby-version: 2.3
46
+ resque-version: 1.27
47
+ rufus-scheduler: 3.5
48
+ - ruby-version: 2.5
49
+ resque-version: 2.2.0
50
+ rufus-scheduler: 3.5
51
+ - ruby-version: 2.5
52
+ resque-version: master
53
+ rufus-scheduler: 3.2
54
+ env:
55
+ RESQUE: "${{ matrix.resque-version }}"
56
+ RUFUS_SCHEDULER: "${{ matrix.rufus-scheduler }}"
57
+ COVERAGE: 1
58
+
59
+ steps:
60
+ - uses: actions/checkout@v3
61
+ - uses: ruby/setup-ruby@v1
62
+ with:
63
+ ruby-version: "${{ matrix.ruby-version }}"
64
+ bundler-cache: true
65
+ - run: bundle exec rake
66
+ - run: bin/bundle_console_test.sh
data/AUTHORS.md CHANGED
@@ -10,6 +10,7 @@ Resque Scheduler authors
10
10
  - Brian Landau
11
11
  - Brian P O'Rourke
12
12
  - Carlos Antonio da Silva
13
+ - Chris Bisnett
13
14
  - Chris Kampmeier
14
15
  - DJ Hartman
15
16
  - Damon P. Cortesi
@@ -27,18 +28,22 @@ Resque Scheduler authors
27
28
  - Harry Lascelles
28
29
  - Henrik Nyh
29
30
  - Hormoz Kheradmand
31
+ - Ian Davies
30
32
  - James Le Cuirot
31
33
  - Jarkko Mönkkönen
34
+ - Jimmy Chao
32
35
  - John Crepezzi
33
36
  - John Griffin
34
37
  - Jon Larkowski and Les Hill
35
38
  - Jonathan Conley
36
39
  - Jonathan Hyman
37
40
  - Jonathan Owens
41
+ - Jordan Gardner
38
42
  - Joshua Szmajda
39
43
  - Justin Weiss
40
44
  - Les Hill
41
45
  - Luke Rodgers
46
+ - Maksymilian Chwałek
42
47
  - Manuel Meurer
43
48
  - Matt Aimonetti
44
49
  - Matt Simpson
@@ -46,6 +51,7 @@ Resque Scheduler authors
46
51
  - Michael Lovitt
47
52
  - Michael Nikitochkin
48
53
  - Michael Rykov
54
+ - Mike MacDonald
49
55
  - Nickolas Means
50
56
  - Olek Janiszewski
51
57
  - Olivier Brisse
@@ -59,11 +65,13 @@ Resque Scheduler authors
59
65
  - Scott Francis
60
66
  - Sean Stephens
61
67
  - Sebastian Kippe
68
+ - Sharang Dashputre
62
69
  - Spring MC
63
70
  - tbprojects
64
71
  - Tim Liner
65
72
  - Tony Lewis
66
73
  - Tom Crayford
74
+ - Tsu-Shiuan Lin
67
75
  - Vincent Zhu
68
76
  - Vladislav Shub
69
77
  - V Sreekanth
@@ -79,3 +87,4 @@ Resque Scheduler authors
79
87
  - malomalo
80
88
  - sawanoboly
81
89
  - serek
90
+ - iloveitaly
data/CHANGELOG.md CHANGED
@@ -2,7 +2,50 @@
2
2
 
3
3
  **ATTN**: This project uses [semantic versioning](http://semver.org/).
4
4
 
5
- ## [Unreleased]
5
+ ## [4.6.0] - 2022-08-04
6
+ ### Changed
7
+ - Remove support for Ruby < 2.3
8
+ - Configuration to use a set of truthy values to enable boolean settings instead of simply existence
9
+ - Add `delay_or_enqueue_at` for delaying existing jobs or creating a new job(#645)
10
+ - Fix deprecated uses of Redis#pipelined
11
+ - Fix reading configuration from environment for boolean values (#735)
12
+ - Unblock rufus-scheduler lock on lower than 3.7 by fixing scheduler shutdown (#736)
13
+ - Removed testing against jruby (resque doesn't test against jruby)
14
+
15
+ ## [4.5.0] - 2021-09-25
16
+ ### Added
17
+ - Support Ruby 3
18
+ - Add optional argument to `remove_schedule` to control reloading of the schedule
19
+
20
+ ### Fixed
21
+ - Fix XSS vulnerability on the `/delayed/search` page
22
+ - Ensure that jobs are directly created for jobs enqueued at `Time.now`
23
+ - Fix queuing to custom job queues in `enqueue_delayed_selection`
24
+ - Ensure `before_enqueue` and `after_enqueue` callbacks are called in all cases of queuing a job
25
+ - Fix redis error when running resque-scheduler without Redis
26
+
27
+ ### Changed
28
+ - Change CI from Travis to GitHub Actions
29
+ - Only allow rufus-scheduler versions lower than 3.7
30
+ - Update vagrant configuration
31
+
32
+ ## [4.4.0] - 2019-04-11
33
+ ### Added
34
+ - Support Resque 2
35
+ - Support redis-rb 4
36
+ - Support Ruby 2.5
37
+
38
+ ### Fixed
39
+ - Redis timeouts no longer crash the scheduler process
40
+ - Fix race condition when running multiple schedulers
41
+ - Fix setting the `poll_sleep_amount` option
42
+ - Escape class names in resque-web /delayed URLs
43
+
44
+ ### Changed
45
+ - Addressed redis-namespace deprecation warnings
46
+ - Ensure `enqueue_in` args are Numeric, catching a common issue passing `ActiveSupport::Duration`
47
+
48
+ ## [4.3.1] - 2017-11-20
6
49
  ### Changed
7
50
  - Add support and testing for ruby 2.4
8
51
  - Change log format and file name
@@ -11,6 +54,7 @@
11
54
 
12
55
  ### Fixed
13
56
  - Reporting version via `resque-scheduler --version`
57
+ - Class name escaping in `/delayed` view
14
58
 
15
59
  ## [4.3.0] - 2016-06-26
16
60
  ### Added
@@ -407,7 +451,10 @@
407
451
  ### Added
408
452
  - Initial release
409
453
 
410
- [Unreleased]: https://github.com/resque/resque-scheduler/compare/v4.3.0...HEAD
454
+ [Unreleased]: https://github.com/resque/resque-scheduler/compare/v4.5.0...HEAD
455
+ [4.5.0]: https://github.com/resque/resque-scheduler/compare/v4.4.0...v4.5.0
456
+ [4.4.0]: https://github.com/resque/resque-scheduler/compare/v4.3.1...v4.4.0
457
+ [4.3.1]: https://github.com/resque/resque-scheduler/compare/v4.3.0...v4.3.1
411
458
  [4.3.0]: https://github.com/resque/resque-scheduler/compare/v4.2.1...v4.3.0
412
459
  [4.2.1]: https://github.com/resque/resque-scheduler/compare/v4.2.0...v4.2.1
413
460
  [4.2.0]: https://github.com/resque/resque-scheduler/compare/v4.1.0...v4.2.0
data/Gemfile CHANGED
@@ -1,4 +1,18 @@
1
1
  # vim:fileencoding=utf-8
2
2
  source 'https://rubygems.org'
3
3
 
4
+ case resque_version = ENV.fetch('RESQUE', 'master')
5
+ when 'master'
6
+ gem 'resque', git: 'https://github.com/resque/resque'
7
+ else
8
+ gem 'resque', resque_version
9
+ end
10
+
11
+ case rufus_scheduler_version = ENV.fetch('RUFUS_SCHEDULER', '3.6')
12
+ when 'master'
13
+ gem 'rufus-scheduler', git: 'https://github.com/jmettraux/rufus-scheduler'
14
+ else
15
+ gem 'rufus-scheduler', rufus_scheduler_version
16
+ end
17
+
4
18
  gemspec
data/README.md CHANGED
@@ -2,10 +2,8 @@ resque-scheduler
2
2
  ================
3
3
 
4
4
 
5
- [![Dependency Status](https://gemnasium.com/badges/github.com/resque/resque-scheduler.svg)](https://gemnasium.com/github.com/resque/resque-scheduler)
6
5
  [![Gem Version](https://badge.fury.io/rb/resque-scheduler.svg)](https://badge.fury.io/rb/resque-scheduler)
7
- [![Build Status](https://travis-ci.org/resque/resque-scheduler.svg?branch=master)](https://travis-ci.org/resque/resque-scheduler)
8
- [![Windows Build Status](https://ci.appveyor.com/api/projects/status/sxvf2086v5j0absb/branch/master?svg=true)](https://ci.appveyor.com/project/resque/resque-scheduler/branch/master)
6
+ [![Ruby specs](https://github.com/resque/resque-scheduler/actions/workflows/ruby.yml/badge.svg)](https://github.com/resque/resque-scheduler/actions)
9
7
  [![Code Climate](https://codeclimate.com/github/resque/resque-scheduler/badges/gpa.svg)](https://codeclimate.com/github/resque/resque-scheduler)
10
8
 
11
9
  ### Description
@@ -13,7 +11,7 @@ resque-scheduler
13
11
  Resque-scheduler is an extension to [Resque](http://github.com/resque/resque)
14
12
  that adds support for queueing items in the future.
15
13
 
16
- Job scheduling is supported in two different way: Recurring (scheduled) and
14
+ Job scheduling is supported in two different ways: Recurring (scheduled) and
17
15
  Delayed.
18
16
 
19
17
  Scheduled jobs are like cron jobs, recurring on a regular basis. Delayed
@@ -160,7 +158,7 @@ following task to wherever tasks are kept, such as
160
158
  ```ruby
161
159
  task 'resque:pool:setup' do
162
160
  Resque::Pool.after_prefork do |job|
163
- Resque.redis.client.reconnect
161
+ Resque.redis._client.reconnect
164
162
  end
165
163
  end
166
164
  ```
@@ -213,7 +211,7 @@ since the jobs are stored in a redis sorted set (zset). I can't imagine this
213
211
  being an issue for someone since redis is stupidly fast even at log(n), but full
214
212
  disclosure is always best.
215
213
 
216
- #### Removing Delayed jobs
214
+ #### Removing Delayed Jobs
217
215
 
218
216
  If you have the need to cancel a delayed job, you can do like so:
219
217
 
@@ -235,6 +233,17 @@ Resque.remove_delayed_selection { |args| args[0]['account_id'] == current_accoun
235
233
  Resque.remove_delayed_selection { |args| args[0]['user_id'] == current_user.id }
236
234
  ```
237
235
 
236
+ If you need to cancel a delayed job based on some matching arguments AND by which class the job is, but don't wish to specify each argument from when the job was created, you can do like so:
237
+
238
+ ``` ruby
239
+ # after you've enqueued a job like:
240
+ Resque.enqueue_at(5.days.from_now, SendFollowUpEmail, :account_id => current_account.id, :user_id => current_user.id)
241
+ # remove jobs matching just the account and that were of the class SendFollowUpEmail:
242
+ Resque.remove_delayed_selection(SendFollowUpEmail) { |args| args[0]['account_id'] == current_account.id }
243
+ # or remove jobs matching just the user and that were of the class SendFollowUpEmail:
244
+ Resque.remove_delayed_selection(SendFollowUpEmail) { |args| args[0]['user_id'] == current_user.id }
245
+ ```
246
+
238
247
  If you need to enqueue immediately a delayed job based on some matching arguments, but don't wish to specify each argument from when the job was created, you can do like so:
239
248
 
240
249
  ``` ruby
@@ -246,6 +255,49 @@ Resque.enqueue_delayed_selection { |args| args[0]['account_id'] == current_accou
246
255
  Resque.enqueue_delayed_selection { |args| args[0]['user_id'] == current_user.id }
247
256
  ```
248
257
 
258
+ #### Updating Delayed Jobs
259
+
260
+ Previously delayed jobs may be delayed even further into the future like so:
261
+
262
+ ```ruby
263
+ # after you've enqueued a job like:
264
+ Resque.enqueue_at(1.minute.from_now, SendNotifications, :user_id => current_user.id)
265
+ # delay running the job until two minutes from now
266
+ Resque.delay_or_enqueue_at(2.minutes.from_now, SendNotifications, :user_id => current_user.id)
267
+ ```
268
+
269
+ You don't need to worry if a matching job has already been queued, because if no matching jobs are found a new job is created and enqueued as if you had called `enqueue_at`. This means you don't need any special conditionals to know if a job has already been queued. You simply create the job like so:
270
+
271
+ ```ruby
272
+ Resque.delay_or_enqueue_at(1.minute.from_now, SendNotifications, :user_id => current_user.id)
273
+ ```
274
+
275
+ If multiple matching jobs are found, all of the matching jobs will be updated to have the same timestamp even if their original timestamps were not the same.
276
+
277
+ ```ruby
278
+ # enqueue multiple jobs with different delay timestamps
279
+ Resque.enqueue_at(1.minute.from_now, SendNotifications, :user_id => current_user.id)
280
+ Resque.enqueue_at(2.minutes.from_now, SendNotifications, :user_id => current_user.id)
281
+
282
+ # delay running the two jobs until 5 minutes from now
283
+ Resque.delay_or_enqueue_at(5.minutes.from_now, SendNotifications, :user_id => current_user.id)
284
+ ```
285
+
286
+ The most useful case for increasing the delay of an already delayed job is to batch together work based on multiple events. For example, if you wanted to send a notification email to a user when an event triggers but didn't want to send 10 emails if many events happened within a short period, you could use this technique to delay the noficication email until no events have triggered for a period of time. This way you could send 1 email containing the 10 notifications once no events have triggered for 2 minutes. You could implement this like so:
287
+
288
+ ```ruby
289
+ # Send a notification when an event is created.
290
+ # app/models/event.rb
291
+ after_commit on: :create do
292
+ Resque.delay_or_enqueue_in(2.minutes, SendNotifications, :user_id => user.id)
293
+ end
294
+ ```
295
+
296
+ When the first event is created a job will be scheduled to send unsent notifications to the associated user. If another event is created within the 2 minute window, the timer will be reset to 2 minutes. This will continue as long as new events are created for the specific user before the 2 minute timer expires. Once the timer expires and the job is scheduled any new events that are created will schedule a new job and start the process over. By adjusting the window you can tweak the trade-off between sending notification emails quickly after an event happens and sending fewer emails.
297
+
298
+ Read more in the [original PR](https://github.com/resque/resque-scheduler/pull/645)
299
+
300
+
249
301
  ### Scheduled Jobs (Recurring Jobs)
250
302
 
251
303
  Scheduled (or recurring) jobs are logically no different than a standard cron
@@ -295,7 +347,6 @@ If you would like to setup a job that is executed manually you can configure lik
295
347
 
296
348
  ```yaml
297
349
  ImportOrdersManual:
298
- description: 'Import Amazon Orders Manual'
299
350
  custom_job_class: 'AmazonMws::ImportOrdersJob'
300
351
  never: "* * * * *"
301
352
  queue: high
@@ -335,11 +386,43 @@ seconds past the minute).
335
386
  A big shout out to [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler)
336
387
  for handling the heavy lifting of the actual scheduling engine.
337
388
 
389
+ ##### Queue with parameters
390
+
391
+ It's possible to specify parameters, that must be given by the user when they manually queue the job. To enable this feature add `parameters` key to scheduled job definition.
392
+
393
+ ```yaml
394
+ queue_documents_for_indexing:
395
+ cron: "0 0 * * *"
396
+ class: "QueueDocuments"
397
+ queue: high
398
+ args:
399
+ foo: "bar"
400
+ a: "b"
401
+ parameters:
402
+ foo:
403
+ description: "value of foo"
404
+ default: "baz"
405
+
406
+ description: "This job queues all content for indexing in solr"
407
+ ```
408
+
409
+ One can use following options for each parameter:
410
+ * description - tooltip to be shown next to the parameter input
411
+ * default - prefilled value in the parameter input
412
+
413
+ **NOTE**: When sheduling the job, parameters are merged into job args. Assuming the example above and default parametr value, the job will be run with the following args:
414
+
415
+ ```ruby
416
+ {"foo"=>"baz", "a"=>"b"}
417
+ ```
418
+
419
+ **NOTE**: If user leaves the parameter value empty, it'll be sent as empty string.
420
+
338
421
  #### Dynamic schedules
339
422
 
340
423
  Dynamic schedules are programmatically set on a running `resque-scheduler`.
341
- All [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler) options are supported
342
- when setting schedules.
424
+ Most [rufus-scheduler](http://github.com/jmettraux/rufus-scheduler) options are supported
425
+ when setting schedules. Specifically the `overlap` option will not work.
343
426
 
344
427
  Dynamic schedules are not enabled by default. To be able to dynamically set schedules, you
345
428
  must pass the following to `resque-scheduler` initialization (see *Installation* above for a more complete example):
@@ -396,18 +479,17 @@ Resque.set_schedule(name, config)
396
479
 
397
480
  #### Time zones
398
481
 
399
- Note that if you use the cron syntax, this will be interpreted as in the server time zone
400
- rather than the `config.time_zone` specified in Rails.
401
-
482
+ If you use the cron syntax, by default it is interpreted in the server time zone.
402
483
  You can explicitly specify the time zone that rufus-scheduler will use:
403
-
404
484
  ```yaml
405
485
  cron: "30 6 * * 1 Europe/Stockholm"
406
486
  ```
407
487
 
408
- Also note that `config.time_zone` in Rails allows for a shorthand (e.g. "Stockholm")
409
- that rufus-scheduler does not accept. If you write code to set the scheduler time zone
410
- from the `config.time_zone` value, make sure it's the right format, e.g. with:
488
+ ##### Rails
489
+ In Rails, `config.time_zone` will be used to determine the time zone for `resque-scheduler`.
490
+
491
+ Note that `config.time_zone` allows for a shorthand (e.g. "Stockholm")
492
+ that rufus-scheduler does not accept, so make sure it's the right format, e.g. with:
411
493
 
412
494
  ```ruby
413
495
  ActiveSupport::TimeZone.find_tzinfo(Rails.configuration.time_zone).name
@@ -516,7 +598,7 @@ RESQUE_SCHEDULER_MASTER_LOCK_PREFIX=MyApp: rake resque:scheduler
516
598
 
517
599
  ### resque-web Additions
518
600
 
519
- Resque-scheduler also adds to tabs to the resque-web UI. One is for viewing
601
+ Resque-scheduler also adds two tabs to the resque-web UI. One is for viewing
520
602
  (and manually queueing) the schedule and one is for viewing pending jobs in
521
603
  the delayed queue.
522
604
 
@@ -550,11 +632,7 @@ require 'resque/scheduler/server'
550
632
 
551
633
  That should make the scheduler tabs show up in `resque-web`.
552
634
 
553
- #### Changes as of 2.0.0
554
-
555
- As of resque-scheduler 2.0.0, it's no longer necessary to have the resque-web
556
- process aware of the schedule because it reads it from redis. But prior to
557
- 2.0, you'll want to make sure you load the schedule in this file as well.
635
+ You'll want to make sure you load the schedule in this file as well.
558
636
  Something like this:
559
637
 
560
638
  ```ruby
@@ -568,7 +646,7 @@ Now make sure you're passing that file to resque-web like so:
568
646
 
569
647
  ### Running in the background
570
648
 
571
- (Only supported with ruby >= 1.9). There are scenarios where it's helpful for
649
+ There are scenarios where it's helpful for
572
650
  the resque worker to run itself in the background (usually in combination with
573
651
  PIDFILE). Use the BACKGROUND option so that rake will return as soon as the
574
652
  worker is started.
@@ -634,7 +712,7 @@ that happens on Travis CI and Appveyor:
634
712
  bundle install
635
713
 
636
714
  # Make sure tests are green before you change stuff
637
- bundle exec rake
715
+ bundle exec rubocop && bundle exec rake
638
716
  # Change stuff
639
717
  # Repeat
640
718
  ```
data/Rakefile CHANGED
@@ -1,13 +1,9 @@
1
1
  # vim:fileencoding=utf-8
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rake/testtask'
4
- require 'rubocop/rake_task'
5
4
  require 'yard'
6
5
 
7
- task default: [:rubocop, :test] unless RUBY_PLATFORM =~ /java/
8
- task default: [:test] if RUBY_PLATFORM =~ /java/
9
-
10
- RuboCop::RakeTask.new
6
+ task default: :test
11
7
 
12
8
  Rake::TestTask.new do |t|
13
9
  t.libs << 'test'
@@ -16,6 +12,7 @@ Rake::TestTask.new do |t|
16
12
  o << "--seed #{ENV['SEED']} " if ENV['SEED']
17
13
  o << '--verbose ' if ENV['VERBOSE']
18
14
  end
15
+ t.warning = false
19
16
  end
20
17
 
21
18
  YARD::Rake::YardocTask.new
@@ -8,13 +8,18 @@ module Resque
8
8
  yield self
9
9
  end
10
10
 
11
+ attr_writer :environment
12
+ def environment
13
+ @environment ||= ENV
14
+ end
15
+
11
16
  # Used in `#load_schedule_job`
12
17
  attr_writer :env
13
18
 
14
19
  def env
15
20
  return @env if @env
16
21
  @env ||= Rails.env if defined?(Rails) && Rails.respond_to?(:env)
17
- @env ||= ENV['RAILS_ENV']
22
+ @env ||= environment['RAILS_ENV']
18
23
  @env
19
24
  end
20
25
 
@@ -22,42 +27,42 @@ module Resque
22
27
  attr_writer :verbose
23
28
 
24
29
  def verbose
25
- @verbose ||= !!ENV['VERBOSE']
30
+ @verbose ||= to_bool(environment['VERBOSE'])
26
31
  end
27
32
 
28
33
  # If set, produces no output
29
34
  attr_writer :quiet
30
35
 
31
36
  def quiet
32
- @quiet ||= !!ENV['QUIET']
37
+ @quiet ||= to_bool(environment['QUIET'])
33
38
  end
34
39
 
35
40
  # If set, will write messages to the file
36
41
  attr_writer :logfile
37
42
 
38
43
  def logfile
39
- @logfile ||= ENV['LOGFILE']
44
+ @logfile ||= environment['LOGFILE']
40
45
  end
41
46
 
42
47
  # Sets whether to log in 'text' or 'json'
43
48
  attr_writer :logformat
44
49
 
45
50
  def logformat
46
- @logformat ||= ENV['LOGFORMAT']
51
+ @logformat ||= environment['LOGFORMAT']
47
52
  end
48
53
 
49
54
  # If set, will try to update the schedule in the loop
50
55
  attr_writer :dynamic
51
56
 
52
57
  def dynamic
53
- @dynamic ||= !!ENV['DYNAMIC_SCHEDULE']
58
+ @dynamic ||= to_bool(environment['DYNAMIC_SCHEDULE'])
54
59
  end
55
60
 
56
61
  # If set, will append the app name to procline
57
62
  attr_writer :app_name
58
63
 
59
64
  def app_name
60
- @app_name ||= ENV['APP_NAME']
65
+ @app_name ||= environment['APP_NAME']
61
66
  end
62
67
 
63
68
  # Amount of time in seconds to sleep between polls of the delayed
@@ -66,7 +71,25 @@ module Resque
66
71
 
67
72
  def poll_sleep_amount
68
73
  @poll_sleep_amount ||=
69
- Float(ENV.fetch('RESQUE_SCHEDULER_INTERVAL', '5'))
74
+ Float(environment.fetch('RESQUE_SCHEDULER_INTERVAL', '5'))
75
+ end
76
+
77
+ private
78
+
79
+ # Copied from https://github.com/rails/rails/blob/main/activemodel/lib/active_model/type/boolean.rb#L17
80
+ TRUE_VALUES = [
81
+ true, 1,
82
+ '1', :'1',
83
+ 't', :t,
84
+ 'T', :T,
85
+ 'true', :true,
86
+ 'TRUE', :TRUE,
87
+ 'on', :on,
88
+ 'ON', :ON
89
+ ].to_set.freeze
90
+
91
+ def to_bool(value)
92
+ TRUE_VALUES.include?(value)
70
93
  end
71
94
  end
72
95
  end