sidekiq_alive 1.1.1 → 2.0.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
  SHA256:
3
- metadata.gz: 353fe633b29953f77cd04c9c7f3fe956c2c258c925de88c98f9ef8bf7338c4fd
4
- data.tar.gz: 2f2e3845a01d3b546cd9dc16829bf7ba196ad53edbd71d6b7a01f7e940f6fb34
3
+ metadata.gz: d3bef9746bd43d32416e55a9f5b8bf719498ae3daa6c50bb018bddecbc49234c
4
+ data.tar.gz: 7f1cb14b61f71af4a4e15437e0395413d9861b86d3a3cf214c0bf5a88dc7e98a
5
5
  SHA512:
6
- metadata.gz: 67ae1f11a7b5f436552c80ef9a389c80b3945444b8ffd04f9ab1c732d8d78ea26ad54fef7e2365ad89f73db33a441429f4a38c57eebad16ba4e3d22c7c7754bb
7
- data.tar.gz: 578c4786ec814f79d6a2acb623a66ad6a732e7365397e573d1b582f051e7b9968971accc824481c0dc6d50e6de89281bdc83650c92e4db5d9d551e4cf2084d64
6
+ metadata.gz: 61789b71b9a1819e38f69763348c06af301f3ac7fb0e4164728a4802db3846700b97aff2b78dec75f44df71b1f230b9d79fff7234d14989639cad50e90ab3347
7
+ data.tar.gz: 2b6e99585bbd51e205a09b16786eeae165b9657c7aa1683fca0feb8c15c20b49b67e83a413ac9960b6f3ae19a44d74480220b52535c9893c9a3ee7ad092b4434
@@ -5,9 +5,13 @@ cache: bundler
5
5
  rvm:
6
6
  - 2.3.7
7
7
  - 2.4.4
8
- - 2.5.1
8
+ - 2.5.5
9
+ - 2.6.2
9
10
  - ruby-head
10
- before_install: gem install bundler -v 1.16.1
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
14
+ before_install: gem install bundler -v 1.17.3
11
15
  env:
12
16
  global:
13
17
  - CC_TEST_REPORTER_ID=571b470a2b61f8a58b2a0ebbcf297805efa07c548e45bac9d1c9ce0c5edcfc20
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in sidekiq_alive.gemspec
6
6
  gemspec
@@ -1,55 +1,48 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sidekiq_alive (1.1.1)
4
+ sidekiq_alive (2.0.3)
5
5
  sidekiq
6
- sinatra
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
10
  coderay (1.1.2)
12
- concurrent-ruby (1.0.5)
13
- connection_pool (2.2.1)
11
+ connection_pool (2.2.2)
14
12
  diff-lcs (1.3)
15
- method_source (0.9.0)
16
- mock_redis (0.18.0)
17
- pry (0.11.3)
13
+ method_source (0.9.2)
14
+ mock_redis (0.19.0)
15
+ pry (0.12.2)
18
16
  coderay (~> 1.1.0)
19
17
  method_source (~> 0.9.0)
20
- rack (1.6.8)
21
- rack-protection (1.5.3)
18
+ rack (2.0.6)
19
+ rack-protection (2.0.5)
22
20
  rack
23
- rack-test (1.0.0)
21
+ rack-test (1.1.0)
24
22
  rack (>= 1.0, < 3)
25
23
  rake (10.5.0)
26
- redis (3.3.5)
27
- rspec (3.7.0)
28
- rspec-core (~> 3.7.0)
29
- rspec-expectations (~> 3.7.0)
30
- rspec-mocks (~> 3.7.0)
31
- rspec-core (3.7.1)
32
- rspec-support (~> 3.7.0)
33
- rspec-expectations (3.7.0)
24
+ redis (4.1.0)
25
+ rspec (3.8.0)
26
+ rspec-core (~> 3.8.0)
27
+ rspec-expectations (~> 3.8.0)
28
+ rspec-mocks (~> 3.8.0)
29
+ rspec-core (3.8.0)
30
+ rspec-support (~> 3.8.0)
31
+ rspec-expectations (3.8.2)
34
32
  diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.7.0)
36
- rspec-mocks (3.7.0)
33
+ rspec-support (~> 3.8.0)
34
+ rspec-mocks (3.8.0)
37
35
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.7.0)
36
+ rspec-support (~> 3.8.0)
39
37
  rspec-sidekiq (3.0.3)
40
38
  rspec-core (~> 3.0, >= 3.0.0)
41
39
  sidekiq (>= 2.4.0)
42
- rspec-support (3.7.1)
43
- sidekiq (4.2.10)
44
- concurrent-ruby (~> 1.0)
45
- connection_pool (~> 2.2, >= 2.2.0)
40
+ rspec-support (3.8.0)
41
+ sidekiq (5.2.5)
42
+ connection_pool (~> 2.2, >= 2.2.2)
43
+ rack (>= 1.5.0)
46
44
  rack-protection (>= 1.5.0)
47
- redis (~> 3.2, >= 3.2.1)
48
- sinatra (1.4.8)
49
- rack (~> 1.5)
50
- rack-protection (~> 1.4)
51
- tilt (>= 1.3, < 3)
52
- tilt (2.0.9)
45
+ redis (>= 3.3.5, < 5)
53
46
 
54
47
  PLATFORMS
55
48
  ruby
@@ -65,4 +58,4 @@ DEPENDENCIES
65
58
  sidekiq_alive!
66
59
 
67
60
  BUNDLED WITH
68
- 1.17.1
61
+ 1.17.3
data/README.md CHANGED
@@ -11,13 +11,30 @@ __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
 
14
- A Sidekiq worker is the responsable to storing this key. If Sidekiq stops processing workers
14
+ A Sidekiq worker is the responsible to storing this key. If Sidekiq stops processing workers
15
15
  this key gets expired by Redis an consequently the http server will return a 500 error.
16
16
 
17
17
  This worker is responsible to requeue itself for the next liveness probe.
18
18
 
19
19
  Each instance in kubernetes will be checked based on `ENV` variable `HOSTNAME` (kubernetes sets this for each replica/pod).
20
20
 
21
+ On initialization SidekiqAlive will asign to Sidekiq::Worker a queue with the current host and add this queue to the current instance queues to process.
22
+
23
+ example:
24
+
25
+ ```
26
+ hostname: foo
27
+ Worker queue: sidekiq_alive-foo
28
+ instance queues:
29
+ - sidekiq_alive-foo
30
+ *- your queues
31
+
32
+ hostname: bar
33
+ Worker queue: sidekiq_alive-bar
34
+ instance queues:
35
+ - sidekiq_alive-bar
36
+ *- your queues
37
+ ```
21
38
 
22
39
  ## Installation
23
40
 
@@ -35,29 +52,21 @@ Or install it yourself as:
35
52
 
36
53
  $ gem install sidekiq_alive
37
54
 
38
- Run `Sidekiq` with a `sidekiq_alive` queue.
39
-
40
- ```
41
- sidekiq -q sidekiq_alive
42
- ```
43
-
44
- or in your config:
45
55
 
46
- _sidekiq.yml_
47
- ```yaml
48
- queues:
49
- - default
50
- - sidekiq_alive
51
- ```
56
+ ## Usage
52
57
 
53
- __IMPORTANT:__
58
+ SidekiqAlive will start when running `sidekiq` command.
54
59
 
55
- Make sure you run a `quiet` every time before you stop the pods [(issue)](https://github.com/arturictus/sidekiq_alive/issues/10). That's not only important for SidekiqAlive it's important that your workers finish before you stop Sidekiq.
56
- Check [recommended kubernetes setup](#kubernetes-setup)
60
+ Run `Sidekiq`
57
61
 
58
- ## Usage
62
+ ```
63
+ bundle exec sidekiq
64
+ ```
59
65
 
60
- SidekiqAlive will start when running `sidekiq` command.
66
+ ```
67
+ curl localhost:7433
68
+ #=> Alive!
69
+ ```
61
70
 
62
71
 
63
72
  __how to disable?__
@@ -74,6 +83,8 @@ Set `livenessProbe` in your Kubernetes deployment
74
83
 
75
84
  example with recommended setup:
76
85
 
86
+ #### Sidekiq < 6
87
+
77
88
  ```yaml
78
89
  spec:
79
90
  containers:
@@ -108,6 +119,63 @@ spec:
108
119
  terminationGracePeriodSeconds: 60 # put your longest Job time here plus security time.
109
120
  ```
110
121
 
122
+ #### Sidekiq >= 6
123
+
124
+ Create file:
125
+
126
+ _kube/sidekiq_quiet_
127
+
128
+ ```bash
129
+ #!/bin/bash
130
+
131
+ # Find Pid
132
+ SIDEKIQ_PID=$(ps aux | grep sidekiq | grep busy | awk '{ print $2 }')
133
+ # Send TSTP signal
134
+ kill -SIGTSTP $SIDEKIQ_PID
135
+ ```
136
+
137
+ Make it executable:
138
+
139
+ ```
140
+ $ chmod +x kube/sidekiq_quiet
141
+ ```
142
+
143
+ Execute it in your deployment preStop:
144
+
145
+ ```yaml
146
+ spec:
147
+ containers:
148
+ - name: my_app
149
+ image: my_app:latest
150
+ env:
151
+ - name: RAILS_ENV
152
+ value: production
153
+ command:
154
+ - bundle
155
+ - exec
156
+ - sidekiq
157
+ ports:
158
+ - containerPort: 7433
159
+ livenessProbe:
160
+ httpGet:
161
+ path: /
162
+ port: 7433
163
+ initialDelaySeconds: 80 # app specific. Time your sidekiq takes to start processing.
164
+ timeoutSeconds: 5 # can be much less
165
+ readinessProbe:
166
+ httpGet:
167
+ path: /
168
+ port: 7433
169
+ initialDelaySeconds: 80 # app specific
170
+ timeoutSeconds: 5 # can be much less
171
+ lifecycle:
172
+ preStop:
173
+ exec:
174
+ # SIGTERM triggers a quick exit; gracefully terminate instead
175
+ command: ["kube/sidekiq_quiet"]
176
+ terminationGracePeriodSeconds: 60 # put your longest Job time here plus security time.
177
+ ```
178
+
111
179
  ### Outside kubernetes
112
180
 
113
181
  It's just up to you how you want to use it.
@@ -129,11 +197,19 @@ curl localhost:7433
129
197
  ```ruby
130
198
  SidekiqAlive.setup do |config|
131
199
  # ==> Server port
132
- # Port to bind the server
200
+ # Port to bind the server.
201
+ # Can also be set with the environment variable SIDEKIQ_ALIVE_PORT.
133
202
  # default: 7433
134
203
  #
135
204
  # config.port = 7433
136
205
 
206
+ # ==> Server path
207
+ # HTTP path to respond to.
208
+ # Can also be set with the environment variable SIDEKIQ_ALIVE_PATH.
209
+ # default: '/'
210
+ #
211
+ # config.path = '/'
212
+
137
213
  # ==> Liveness key
138
214
  # Key to be stored in Redis as probe of liveness
139
215
  # default: "SIDEKIQ::LIVENESS_PROBE_TIMESTAMP"
@@ -156,17 +232,20 @@ SidekiqAlive.setup do |config|
156
232
  # require 'net/http'
157
233
  # config.callback = proc { Net::HTTP.get("https://status.com/ping") }
158
234
 
159
- # ==> Preferred Queue
160
- # Sidekiq Alive will try to enqueue the workers to this queue. If not found
161
- # will do it to the first available queue.
162
- # It's a good practice to add a dedicated queue for sidekiq alive. If the queue
163
- # where sidekiq is processing SidekiqALive gets overloaded and takes
164
- # longer than the `ttl` to process SidekiqAlive::Worker will make the liveness probe
165
- # to fail. Sidekiq overloaded and restarting every `ttl` cicle.
166
- # Add the sidekiq alive queue!!
235
+ # ==> Queue Prefix
236
+ # SidekiqAlive will run in a independent queue for each instance/replica
237
+ # This queue name will be generated with: "#{queue_prefix}-#{hostname}.
238
+ # You can customize the prefix here.
167
239
  # default: :sidekiq_alive
168
240
  #
169
- # config.preferred_queue = :other
241
+ # config.queue_prefix = :other
242
+
243
+ # ==> Rack server
244
+ # Web server used to serve an HTTP response.
245
+ # Can also be set with the environment variable SIDEKIQ_ALIVE_SERVER.
246
+ # default: 'webrick'
247
+ #
248
+ # config.server = 'puma'
170
249
  end
171
250
  ```
172
251
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "sidekiq_alive"
3
+ require 'bundler/setup'
4
+ require 'sidekiq_alive'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "sidekiq_alive"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start(__FILE__)
@@ -1,41 +1,43 @@
1
- require "sidekiq"
2
- require "singleton"
3
- require "sidekiq_alive/version"
4
- require "sidekiq_alive/config"
1
+ require 'sidekiq'
2
+ require 'sidekiq/api'
3
+ require 'singleton'
4
+ require 'sidekiq_alive/version'
5
+ require 'sidekiq_alive/config'
5
6
 
6
7
  module SidekiqAlive
7
8
  def self.start
8
- Sidekiq.configure_server do |config|
9
+ SidekiqAlive::Worker.sidekiq_options queue: current_queue
10
+ Sidekiq.configure_server do |sq_config|
9
11
 
10
- SidekiqAlive::Worker.sidekiq_options queue: SidekiqAlive.select_queue(config.options[:queues])
12
+ sq_config.options[:queues] << current_queue
11
13
 
12
- config.on(:startup) do
14
+ sq_config.on(:startup) do
13
15
  SidekiqAlive.tap do |sa|
14
16
  sa.logger.info(banner)
15
17
  sa.register_current_instance
16
18
  sa.store_alive_key
17
19
  sa::Worker.perform_async(hostname)
18
- sa::Server.start
20
+ @server_pid = fork do
21
+ sa::Server.run!
22
+ end
19
23
  sa.logger.info(successful_startup_text)
20
24
  end
21
25
  end
22
26
 
23
- config.on(:quiet) do
27
+ sq_config.on(:quiet) do
24
28
  SidekiqAlive.unregister_current_instance
25
29
  end
26
- config.on(:shutdown) do
30
+
31
+ sq_config.on(:shutdown) do
32
+ Process.kill('TERM', @server_pid) unless @server_pid.nil?
33
+ Process.wait(@server_pid) unless @server_pid.nil?
27
34
  SidekiqAlive.unregister_current_instance
28
35
  end
29
36
  end
30
-
31
37
  end
32
38
 
33
- def self.select_queue(queues)
34
- @queue = if queues.find { |e| e.to_sym == config.preferred_queue.to_sym }
35
- config.preferred_queue.to_sym
36
- else
37
- queues.first
38
- end
39
+ def self.current_queue
40
+ "#{config.queue_prefix}-#{hostname}"
39
41
  end
40
42
 
41
43
  def self.register_current_instance
@@ -43,6 +45,9 @@ module SidekiqAlive
43
45
  end
44
46
 
45
47
  def self.unregister_current_instance
48
+ # Delete any pending jobs for this instance
49
+ logger.info(shutdown_info)
50
+ purge_pending_jobs
46
51
  redis.del(current_instance_register_key)
47
52
  end
48
53
 
@@ -50,6 +55,18 @@ module SidekiqAlive
50
55
  redis.keys("#{config.registered_instance_key}::*")
51
56
  end
52
57
 
58
+ def self.purge_pending_jobs
59
+ # TODO:
60
+ # Sidekiq 6 allows better way to find scheduled jobs:
61
+ # https://github.com/mperham/sidekiq/wiki/API#scan
62
+ scheduled_set = Sidekiq::ScheduledSet.new
63
+ jobs = scheduled_set.select { |job| job.klass == 'SidekiqAlive::Worker' && job.queue == current_queue }
64
+ logger.info("[SidekiqAlive] Purging #{jobs.count} pending for #{hostname}")
65
+ jobs.each(&:delete)
66
+ logger.info("[SidekiqAlive] Removing queue #{current_queue}")
67
+ Sidekiq::Queue.new(current_queue).clear
68
+ end
69
+
53
70
  def self.current_instance_register_key
54
71
  "#{config.registered_instance_key}::#{hostname}"
55
72
  end
@@ -57,7 +74,7 @@ module SidekiqAlive
57
74
  def self.store_alive_key
58
75
  redis.set(current_lifeness_key,
59
76
  Time.now.to_i,
60
- { ex: config.time_to_live.to_i })
77
+ ex: config.time_to_live.to_i)
61
78
  end
62
79
 
63
80
  def self.redis
@@ -65,7 +82,7 @@ module SidekiqAlive
65
82
  end
66
83
 
67
84
  def self.alive?
68
- redis.ttl(current_lifeness_key) == -2 ? false : true
85
+ redis.ttl(current_lifeness_key) != -2
69
86
  end
70
87
 
71
88
  # CONFIG ---------------------------------------
@@ -90,8 +107,20 @@ module SidekiqAlive
90
107
  ENV['HOSTNAME'] || 'HOSTNAME_NOT_SET'
91
108
  end
92
109
 
110
+ def self.shutdown_info
111
+ <<~BANNER
112
+
113
+ =================== Shutting down SidekiqAlive =================
114
+
115
+ Hostname: #{hostname}
116
+ Liveness key: #{current_lifeness_key}
117
+ Current instance register key: #{current_instance_register_key}
118
+
119
+ BANNER
120
+ end
121
+
93
122
  def self.banner
94
- <<-BANNER.strip_heredoc
123
+ <<~BANNER
95
124
 
96
125
  =================== SidekiqAlive =================
97
126
 
@@ -108,7 +137,7 @@ module SidekiqAlive
108
137
  end
109
138
 
110
139
  def self.successful_startup_text
111
- <<-BANNER.strip_heredoc
140
+ <<~BANNER
112
141
  Registered instances:
113
142
 
114
143
  - #{registered_instances.join("\n\s\s- ")}
@@ -120,11 +149,11 @@ module SidekiqAlive
120
149
  def self.register_instance(instance_name)
121
150
  redis.set(instance_name,
122
151
  Time.now.to_i,
123
- { ex: config.time_to_live.to_i + 60 })
152
+ ex: config.registration_ttl.to_i)
124
153
  end
125
154
  end
126
155
 
127
- require "sidekiq_alive/worker"
128
- require "sidekiq_alive/server"
156
+ require 'sidekiq_alive/worker'
157
+ require 'sidekiq_alive/server'
129
158
 
130
159
  SidekiqAlive.start unless ENV['DISABLE_SIDEKIQ_ALIVE']
@@ -1,13 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqAlive
2
4
  class Config
3
5
  include Singleton
4
6
 
5
7
  attr_accessor :port,
8
+ :path,
6
9
  :liveness_key,
7
10
  :time_to_live,
8
11
  :callback,
9
12
  :registered_instance_key,
10
- :preferred_queue
13
+ :queue_prefix,
14
+ :server
11
15
 
12
16
  def initialize
13
17
  set_defaults
@@ -15,12 +19,17 @@ module SidekiqAlive
15
19
 
16
20
  def set_defaults
17
21
  @port = ENV['SIDEKIQ_ALIVE_PORT'] || 7433
22
+ @path = ENV['SIDEKIQ_ALIVE_PATH'] || '/'
18
23
  @liveness_key = 'SIDEKIQ::LIVENESS_PROBE_TIMESTAMP'
19
24
  @time_to_live = 10 * 60
20
25
  @callback = proc {}
21
- @registered_instance_key = "SIDEKIQ_REGISTERED_INSTANCE"
22
- @preferred_queue = :sidekiq_alive
26
+ @registered_instance_key = 'SIDEKIQ_REGISTERED_INSTANCE'
27
+ @queue_prefix = :sidekiq_alive
28
+ @server = ENV['SIDEKIQ_ALIVE_SERVER'] || 'webrick'
23
29
  end
24
30
 
31
+ def registration_ttl
32
+ @registration_ttl || time_to_live + 60
33
+ end
25
34
  end
26
35
  end
@@ -1,30 +1,40 @@
1
- require "sinatra/base"
2
- require_relative "./config"
3
- module SidekiqAlive
4
- class Server < Sinatra::Base
5
- set :bind, '0.0.0.0'
1
+ # frozen_string_literal: true
2
+
3
+ require 'rack'
6
4
 
5
+ module SidekiqAlive
6
+ class Server
7
7
  class << self
8
- def start
9
- set :port, SidekiqAlive.config.port
10
- Thread.start { run! }
8
+ def run!
9
+ handler = Rack::Handler.get(server)
10
+
11
+ Signal.trap('TERM') { handler.shutdown }
12
+
13
+ handler.run(self, Port: port, Host: '0.0.0.0')
11
14
  end
12
15
 
13
- def quit!
14
- super
15
- exit
16
+ def port
17
+ SidekiqAlive.config.port
18
+ end
19
+
20
+ def path
21
+ SidekiqAlive.config.path
22
+ end
23
+
24
+ def server
25
+ SidekiqAlive.config.server
16
26
  end
17
- end
18
27
 
19
- get '/' do
20
- if SidekiqAlive.alive?
21
- status 200
22
- body "Alive!"
23
- else
24
- response = "Can't find the alive key"
25
- SidekiqAlive.logger.error(response)
26
- status 404
27
- body response
28
+ def call(env)
29
+ if Rack::Request.new(env).path != path
30
+ [404, {}, ['Not found']]
31
+ elsif SidekiqAlive.alive?
32
+ [200, {}, ['Alive!']]
33
+ else
34
+ response = "Can't find the alive key"
35
+ SidekiqAlive.logger.error(response)
36
+ [404, {}, [response]]
37
+ end
28
38
  end
29
39
  end
30
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SidekiqAlive
2
- VERSION = "1.1.1"
4
+ VERSION = '2.0.3'
3
5
  end
@@ -3,16 +3,10 @@ module SidekiqAlive
3
3
  include Sidekiq::Worker
4
4
  sidekiq_options retry: false
5
5
 
6
- def perform(hostname = SidekiqAlive.hostname)
7
- return unless hostname_registered?(hostname)
8
- if current_hostname == hostname
9
- write_living_probe
10
- # schedule next living probe
11
- self.class.perform_in(config.time_to_live / 2, current_hostname)
12
- else
13
- # requeue for hostname to validate it's own liveness probe
14
- self.class.perform_async(hostname)
15
- end
6
+ def perform(_hostname = SidekiqAlive.hostname)
7
+ write_living_probe
8
+ # schedule next living probe
9
+ self.class.perform_in(config.time_to_live / 2, current_hostname)
16
10
  end
17
11
 
18
12
  def hostname_registered?(hostname)
@@ -27,7 +21,11 @@ module SidekiqAlive
27
21
  # Increment ttl for current registered instance
28
22
  SidekiqAlive.register_current_instance
29
23
  # after callbacks
30
- config.callback.call()
24
+ begin
25
+ config.callback.call
26
+ rescue StandardError
27
+ nil
28
+ end
31
29
  end
32
30
 
33
31
  def current_hostname
@@ -1,16 +1,15 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "sidekiq_alive/version"
3
+ require 'sidekiq_alive/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "sidekiq_alive"
6
+ spec.name = 'sidekiq_alive'
8
7
  spec.version = SidekiqAlive::VERSION
9
- spec.authors = ["Artur Pañach"]
10
- spec.email = ["arturictus@gmail.com"]
8
+ spec.authors = ['Artur Pañach']
9
+ spec.email = ['arturictus@gmail.com']
11
10
 
12
- spec.summary = %q{Liveness probe for sidekiq on Kubernetes deployments.}
13
- spec.description = %q{SidekiqAlive offers a solution to add liveness probe of a Sidekiq instance.
11
+ spec.summary = 'Liveness probe for sidekiq on Kubernetes deployments.'
12
+ spec.description = 'SidekiqAlive offers a solution to add liveness probe of a Sidekiq instance.
14
13
 
15
14
  How?
16
15
 
@@ -19,23 +18,22 @@ Gem::Specification.new do |spec|
19
18
  A Sidekiq job is the responsable to storing this key. If Sidekiq stops processing jobs
20
19
  this key gets expired by Redis an consequently the http server will return a 500 error.
21
20
 
22
- This Job is responsible to requeue itself for the next liveness probe.}
23
- spec.homepage = "https://github.com/arturictus/sidekiq_alive"
24
- spec.license = "MIT"
21
+ This Job is responsible to requeue itself for the next liveness probe.'
22
+ spec.homepage = 'https://github.com/arturictus/sidekiq_alive'
23
+ spec.license = 'MIT'
25
24
 
26
25
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
26
  f.match(%r{^(test|spec|features)/})
28
27
  end
29
- spec.bindir = "exe"
28
+ spec.bindir = 'exe'
30
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
- spec.require_paths = ["lib"]
32
-
33
- spec.add_development_dependency "bundler", "~> 1.16"
34
- spec.add_development_dependency "rake", "~> 10.0"
35
- spec.add_development_dependency "rspec", "~> 3.0"
36
- spec.add_development_dependency "rack-test"
37
- spec.add_development_dependency "rspec-sidekiq", "~> 3.0"
38
- spec.add_development_dependency "mock_redis"
39
- spec.add_dependency "sidekiq"
40
- spec.add_dependency "sinatra"
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.16'
33
+ spec.add_development_dependency 'mock_redis'
34
+ spec.add_development_dependency 'rack-test'
35
+ spec.add_development_dependency 'rake', '~> 10.0'
36
+ spec.add_development_dependency 'rspec', '~> 3.0'
37
+ spec.add_development_dependency 'rspec-sidekiq', '~> 3.0'
38
+ spec.add_dependency 'sidekiq'
41
39
  end
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: 1.1.1
4
+ version: 2.0.3
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: 2019-09-20 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,33 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
28
+ name: mock_redis
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '3.0'
33
+ version: '0'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '3.0'
40
+ version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rack-test
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,49 +53,49 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: rspec-sidekiq
56
+ name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '3.0'
61
+ version: '10.0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '3.0'
68
+ version: '10.0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: mock_redis
70
+ name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '3.0'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '3.0'
97
83
  - !ruby/object:Gem::Dependency
98
- name: sidekiq
84
+ name: rspec-sidekiq
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
89
+ version: '3.0'
90
+ type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '3.0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: sinatra
98
+ name: sidekiq
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -175,8 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
161
  - !ruby/object:Gem::Version
176
162
  version: '0'
177
163
  requirements: []
178
- rubyforge_project:
179
- rubygems_version: 2.7.6
164
+ rubygems_version: 3.0.3
180
165
  signing_key:
181
166
  specification_version: 4
182
167
  summary: Liveness probe for sidekiq on Kubernetes deployments.