resque-heroku-signals 1.27.4.1 → 2.1.0

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
- SHA1:
3
- metadata.gz: d5132b492fff85cf94f3eb40020be2db975ec429
4
- data.tar.gz: ca1220cdbd9711c5330d34e41fa50ad54f69609f
2
+ SHA256:
3
+ metadata.gz: 06d283931f3e67ef19cc510880cee4bffa7461d7430c65f7545a78123d0f990e
4
+ data.tar.gz: 7f096f1604e85e978c2aedbaf509149c623f5e3934a4cb5bb0a7f3deb055a3fc
5
5
  SHA512:
6
- metadata.gz: a62bda832166979be5ec4ef9a7e62b6581b0f1992eae9b2444ec35f723738690dcf2d2c3f40fa49da45f396304fa1ed9271d946f3de82c73e0a2b2af3b69d1ba
7
- data.tar.gz: da0e78106868f5794a423092a7979d2cf58a167ec0fa0b50b50be4a2d995c4ca6a5faf7f5c4603320fdfc21e5cf14d562bfbb88b55eea8e51f33a8fc8b13915f
6
+ metadata.gz: 2e4234285eb296c8e3b8e922f6d3facc458d8d5606fea240374d60ff5551ef752233e0b3e069f9d552ec35148e2d96582609c7355994af22865f9465fc1a8629
7
+ data.tar.gz: '0824cbbf9bda2c4676144cd700adc6b179cb28bbcf8ff9523ff512b7d3cda19440dbe6da1b8e6b01c8ddb3ae9e4fe90aa820eb1cf46d8486c82a96f981da8b5a'
@@ -0,0 +1,24 @@
1
+ on: [push, pull_request]
2
+
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ services:
7
+ redis:
8
+ image: redis
9
+ ports:
10
+ - 6379:6379
11
+ strategy:
12
+ matrix:
13
+ ruby-version: ['3.0', 2.7, 2.6, 2.5, 2.4]
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby ${{ matrix.ruby-version }}
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby-version }}
21
+ - name: Install dependencies
22
+ run: bundle install
23
+ - name: Run tests
24
+ run: bundle exec rake
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.3
data/Gemfile CHANGED
@@ -1,2 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
+
4
+ gem 'pry'
5
+ gem 'pry-byebug'
data/README.md CHANGED
@@ -15,7 +15,15 @@ Add this line to your application's Gemfile:
15
15
  gem 'resque-heroku-signals'
16
16
  ```
17
17
 
18
- Since this gem monkeypatches the Heroku worker the `gemspec` is locked to a `x.x.x` version of Resque. Issue a PR if this is not compatible with the version of resque you are using.
18
+ Since this gem monkeypatches the Heroku worker the `gemspec` is locked to a `x.x.x` version of Resque to ensure the monkeypatched logic is compatible with any changes in the original Resque logic. Issue a PR if this is not compatible with the version of resque you are using.
19
+
20
+ ## Determining When a Process Will Shutdown
21
+
22
+ Heroku sends a `TERM` signal to a process before hard killing it. If your job communicates with slow external APIs, you may want to make sure you have enough time to receive and handle the response from the external system before executing the API requests.
23
+
24
+ Ideally, using an idempotency key with each external API request is the best way to ensure that a given API request only runs. However, depending on your application logic this may not be practical and knowing if a process will be terminated in less than 30s by Heroku is a useful tool.
25
+
26
+ Use `Resque.heroku_will_terminate?` to determine if Heroku will terminate your process within 30s.
19
27
 
20
28
  ## Example Procfile
21
29
 
@@ -28,7 +36,7 @@ worker: env QUEUE=* TERM_CHILD=1 INTERVAL=0.1 RESQUE_PRE_SHUTDOWN_TIMEOUT=20 RES
28
36
  * Total shutdown time should be less than 30s. This is the time [Heroku gives you to cleanup before a `SIGKILL` is issued](https://devcenter.heroku.com/articles/dynos#shutdown)
29
37
  * `INTERVAL` seconds to wait between jobs
30
38
 
31
- Also, make you don't buffer logs: import log messages could fail to push to stdout during the worker shutdown process:
39
+ Also, make you don't buffer logs: important log messages could fail to push to stdout during the worker shutdown process:
32
40
 
33
41
  ```ruby
34
42
  $stdout.sync = true
@@ -1,10 +1,21 @@
1
1
  require 'resque'
2
- require "resque/heroku/version"
3
2
 
3
+ $HEROKU_WILL_TERMINATE_RESQUE = false
4
+
5
+ Resque.class_eval do
6
+ def self.heroku_will_terminate?
7
+ !!$HEROKU_WILL_TERMINATE_RESQUE
8
+ end
9
+ end
10
+
11
+ # before bumping resque dependency, check to ensure implementation has not changed
12
+ # https://github.com/resque/resque/blame/v2.0.0/lib/resque/worker.rb#L406
4
13
  # https://github.com/resque/resque/issues/1559#issuecomment-310908574
5
14
  Resque::Worker.class_eval do
6
15
  def unregister_signal_handlers
7
16
  trap('TERM') do
17
+ $HEROKU_WILL_TERMINATE_RESQUE = true
18
+
8
19
  trap('TERM') do
9
20
  log_with_severity :info, "[resque-heroku] received second term signal, throwing term exception"
10
21
 
@@ -16,7 +27,6 @@ Resque::Worker.class_eval do
16
27
  end
17
28
 
18
29
  log_with_severity :info, "[resque-heroku] received first term signal from heroku, ignoring"
19
-
20
30
  end
21
31
 
22
32
  trap('INT', 'DEFAULT')
@@ -1,16 +1,14 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'resque/heroku/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "resque-heroku-signals"
8
- spec.version = Resque::HerokuSignals::VERSION
7
+ spec.version = '2.1.0'
9
8
  spec.authors = ["Michael Bianco"]
10
- spec.email = ["mike@suitesync.io"]
9
+ spec.email = ["mike@mikebian.co"]
11
10
 
12
11
  spec.summary = "Patch resque to be compatible with the Heroku platform"
13
- # spec.description = %q{TODO: Write a longer description or delete this line.}
14
12
  spec.homepage = "https://github.com/iloveitaly/resque-heroku-signals"
15
13
  spec.license = "MIT"
16
14
 
@@ -21,9 +19,10 @@ Gem::Specification.new do |spec|
21
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
20
  spec.require_paths = ["lib"]
23
21
 
24
- spec.add_dependency "resque", "1.27.4"
22
+ # strict resque dependency is intentional
23
+ spec.add_dependency "resque", "2.1.0"
25
24
 
26
- spec.add_development_dependency "bundler", "~> 1.14"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "bundler", "~> 2.2"
26
+ spec.add_development_dependency "rake", "~> 13.0"
27
+ spec.add_development_dependency "rspec", "~> 3.10"
29
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-heroku-signals
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.4.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bianco
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2021-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque
@@ -16,79 +16,80 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.27.4
19
+ version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.27.4
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: '2.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.14'
40
+ version: '2.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '3.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
69
- description:
68
+ version: '3.10'
69
+ description:
70
70
  email:
71
- - mike@suitesync.io
71
+ - mike@mikebian.co
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".github/workflows/ci.yml"
76
77
  - ".gitignore"
77
78
  - ".rspec"
79
+ - ".ruby-version"
78
80
  - Gemfile
79
81
  - LICENSE.txt
80
82
  - README.md
81
83
  - Rakefile
82
84
  - bin/console
83
85
  - bin/setup
84
- - lib/resque/heroku-signals.rb
85
- - lib/resque/heroku/version.rb
86
+ - lib/resque-heroku-signals.rb
86
87
  - resque-heroku-signals.gemspec
87
88
  homepage: https://github.com/iloveitaly/resque-heroku-signals
88
89
  licenses:
89
90
  - MIT
90
91
  metadata: {}
91
- post_install_message:
92
+ post_install_message:
92
93
  rdoc_options: []
93
94
  require_paths:
94
95
  - lib
@@ -103,9 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.5.1
108
- signing_key:
107
+ rubygems_version: 3.1.6
108
+ signing_key:
109
109
  specification_version: 4
110
110
  summary: Patch resque to be compatible with the Heroku platform
111
111
  test_files: []
@@ -1,5 +0,0 @@
1
- module Resque
2
- module HerokuSignals
3
- VERSION = "1.27.4.1"
4
- end
5
- end