sidekiq_alive 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6d5a90f1ac023c49440e1e24d53e05bd3fe1f5362822e125a8989981e51846e
4
- data.tar.gz: dd90cc1b6d7b1fc6273426e32f950d68a71eaa7d63b42b32d914450f35eec09a
3
+ metadata.gz: cf72b576226b373f7e661aae05d54ec27fcb3e5f612036ab86bd89a18d23b289
4
+ data.tar.gz: f3148f40e24f04bf743b3f097a12045554109a2a8af965e7d84ef9344f7b4c23
5
5
  SHA512:
6
- metadata.gz: 533ef08f31e90ac4743577c561f3994c2b2e7eb9945cadcc4dc70dda3e2b339d8d8e6ab2d270b82a65dc884812b8d30ce1de49e50648af1a4136eafa77ee9dd3
7
- data.tar.gz: 702c96b61ecaa7595b44ff9bd3dcfa29d58e99623a5fcd5534b94221dd92e96b06e0e81f217c826f7d8ee9e75bee55ef063d93ff855381efa5ead8af96a01cc4
6
+ metadata.gz: 56b9231da7d95a74a0a0067ca06a91b921502af01b0da62975dfd4b89dcbc2a9694ce3bf6925dac2cc3f9ba1c5453e1627c4a44432a65f5b2fb17a66ee5ef8af
7
+ data.tar.gz: 9c116fef8bfbfe1db518408b38b2abc3701faf39e21273073e9ca86d295e0c827fa843153fd8e6d9be6d52740203261351292e6f19e3cb6da25b0f639c379d26
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sidekiq_alive (2.0.5)
4
+ sidekiq_alive (2.0.6)
5
5
  sidekiq
6
6
 
7
7
  GEM
@@ -15,7 +15,7 @@ GEM
15
15
  pry (0.12.2)
16
16
  coderay (~> 1.1.0)
17
17
  method_source (~> 0.9.0)
18
- rack (2.0.6)
18
+ rack (2.2.3)
19
19
  rack-protection (2.0.5)
20
20
  rack
21
21
  rack-test (1.1.0)
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  SidekiqAlive offers a solution to add liveness probe for a Sidekiq instance deployed in Kubernetes.
8
8
  This library can be used to check sidekiq health outside kubernetes.
9
9
 
10
- __How?__
10
+ **How?**
11
11
 
12
12
  A http server is started and on each requests validates that a liveness key is stored in Redis. If it is there means is working.
13
13
 
@@ -52,7 +52,6 @@ Or install it yourself as:
52
52
 
53
53
  $ gem install sidekiq_alive
54
54
 
55
-
56
55
  ## Usage
57
56
 
58
57
  SidekiqAlive will start when running `sidekiq` command.
@@ -68,8 +67,7 @@ curl localhost:7433
68
67
  #=> Alive!
69
68
  ```
70
69
 
71
-
72
- __how to disable?__
70
+ **how to disable?**
73
71
  You can disabled by setting `ENV` variable `DISABLE_SIDEKIQ_ALIVE`
74
72
  example:
75
73
 
@@ -115,7 +113,7 @@ spec:
115
113
  preStop:
116
114
  exec:
117
115
  # SIGTERM triggers a quick exit; gracefully terminate instead
118
- command: ["bundle", "exec", "sidekiqctl", "quiet"]
116
+ command: ['bundle', 'exec', 'sidekiqctl', 'quiet']
119
117
  terminationGracePeriodSeconds: 60 # put your longest Job time here plus security time.
120
118
  ```
121
119
 
@@ -172,7 +170,7 @@ spec:
172
170
  preStop:
173
171
  exec:
174
172
  # SIGTERM triggers a quick exit; gracefully terminate instead
175
- command: ["kube/sidekiq_quiet"]
173
+ command: ['kube/sidekiq_quiet']
176
174
  terminationGracePeriodSeconds: 60 # put your longest Job time here plus security time.
177
175
  ```
178
176
 
@@ -217,6 +215,13 @@ SidekiqAlive.setup do |config|
217
215
  #
218
216
  # config.path = '/'
219
217
 
218
+ # ==> Custom Liveness Probe
219
+ # Extra check to decide if restart the pod or not for example connection to DB.
220
+ # `false`, `nil` or `raise` will not write the liveness probe
221
+ # default: proc { true }
222
+ #
223
+ # config.custom_liveness_probe = proc { db_running? }
224
+
220
225
  # ==> Liveness key
221
226
  # Key to be stored in Redis as probe of liveness
222
227
  # default: "SIDEKIQ::LIVENESS_PROBE_TIMESTAMP"
@@ -12,7 +12,8 @@ module SidekiqAlive
12
12
  :callback,
13
13
  :registered_instance_key,
14
14
  :queue_prefix,
15
- :server
15
+ :server,
16
+ :custom_liveness_probe
16
17
 
17
18
  def initialize
18
19
  set_defaults
@@ -28,6 +29,7 @@ module SidekiqAlive
28
29
  @registered_instance_key = 'SIDEKIQ_REGISTERED_INSTANCE'
29
30
  @queue_prefix = :sidekiq_alive
30
31
  @server = ENV['SIDEKIQ_ALIVE_SERVER'] || 'webrick'
32
+ @custom_liveness_probe = proc { true }
31
33
  end
32
34
 
33
35
  def registration_ttl
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqAlive
4
- VERSION = '2.0.5'
4
+ VERSION = '2.0.6'
5
5
  end
@@ -1,11 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqAlive
2
4
  class Worker
3
5
  include Sidekiq::Worker
4
6
  sidekiq_options retry: false
5
7
 
6
8
  def perform(_hostname = SidekiqAlive.hostname)
9
+ # Checks if custom liveness probe passes should fail or return false
10
+ return unless config.custom_liveness_probe.call
11
+
12
+ # Writes the liveness in Redis
7
13
  write_living_probe
8
- # schedule next living probe
14
+ # schedules next living probe
9
15
  self.class.perform_in(config.time_to_live / 2, current_hostname)
10
16
  end
11
17
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_alive
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artur Pañach
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-29 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler