resque-heroku-signals 1.27.4.2 → 1.27.4.3

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
  SHA1:
3
- metadata.gz: 32e4dc2857b3a023cebda645c4de0471c5ec8c6c
4
- data.tar.gz: 2909dac3fe78ac1dc81148738a12d973647af6a0
3
+ metadata.gz: b9c16646fceadc63c6de9f13561c375add6161ec
4
+ data.tar.gz: 852b25d7b002bc6c4c93caaa2ee587a9b5b53625
5
5
  SHA512:
6
- metadata.gz: 3a7bf798568412f2343f842e3ffc45de06f673728368b2084b9c810a0dcf3e3948d775a0005befbc5a47ba2c863924f3db0ce43af2926b21fc66a618d6c6b418
7
- data.tar.gz: f85109d7c9739200a0c258ed457c514417b2dde880076b542327d50ae71b9b9d5f960bfa780cfce42a965d54f9947ac732f231f57a9aeb126cf4e135f3068f75
6
+ metadata.gz: f966ab995b091384bf764b7305bc8459502bdcb03307878277e92b8f46afb88d84baaf029fa432432d29fbbcdeb95d8f0334c4a75d1554fa9f5a8bf1d477624e
7
+ data.tar.gz: 2949155a0ad39b5463b933429dafc039cb6efe4ac6e113db7cf498223aadcc0d29acb71fd15c137e69cb7b86aadc1334ac8589c06f70106e3af25f139b876069
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. 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,9 +1,19 @@
1
1
  require 'resque'
2
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
+
3
11
  # https://github.com/resque/resque/issues/1559#issuecomment-310908574
4
12
  Resque::Worker.class_eval do
5
13
  def unregister_signal_handlers
6
14
  trap('TERM') do
15
+ $HEROKU_WILL_TERMINATE_RESQUE = true
16
+
7
17
  trap('TERM') do
8
18
  log_with_severity :info, "[resque-heroku] received second term signal, throwing term exception"
9
19
 
@@ -15,7 +25,6 @@ Resque::Worker.class_eval do
15
25
  end
16
26
 
17
27
  log_with_severity :info, "[resque-heroku] received first term signal from heroku, ignoring"
18
-
19
28
  end
20
29
 
21
30
  trap('INT', 'DEFAULT')
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "resque-heroku-signals"
7
- spec.version = '1.27.4.2'
7
+ spec.version = '1.27.4.3'
8
8
  spec.authors = ["Michael Bianco"]
9
9
  spec.email = ["mike@suitesync.io"]
10
10
 
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.2
4
+ version: 1.27.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bianco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2018-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque