sidekiq_alive 2.1.7 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/sidekiq_alive/config.rb +11 -8
- data/lib/sidekiq_alive/helpers.rb +27 -0
- data/lib/sidekiq_alive/redis/base.rb +33 -0
- data/lib/sidekiq_alive/redis/client.rb +31 -0
- data/lib/sidekiq_alive/redis/client_adapter.rb +23 -0
- data/lib/sidekiq_alive/server.rb +5 -5
- data/lib/sidekiq_alive/version.rb +1 -1
- data/lib/sidekiq_alive.rb +118 -136
- metadata +92 -40
- data/.github/workflows/test.yml +0 -41
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.tool-versions +0 -1
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -60
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/docker-compose.yml +0 -6
- data/sidekiq_alive.gemspec +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a1531edeeb59ff8e59f1ea95bc3a9456b3893658254b1aa1dd9bd046b774914
|
4
|
+
data.tar.gz: 5c8fdbcd1c8ca43fb3e3b461d94049fdf27e8663ee9aafb8bfcac8761f96a6c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5cb97906bd942c5c65b95537c75d1f39f77b7154845c2a6bd748e02b005d8103c76510eedb8e2676183c201cd21067e1f73fa7986681c858e6d8de477eac987
|
7
|
+
data.tar.gz: 2a581a73a2b9825681f3904d7d6d69af8faf10db1a117c037836f07a21c8b43931db6cfdb40bfaff5d6b27806b64b8d73e4c26c6951c0a1710245f4da3a7f3bf
|
data/README.md
CHANGED
@@ -244,11 +244,19 @@ SidekiqAlive.setup do |config|
|
|
244
244
|
# require 'net/http'
|
245
245
|
# config.callback = proc { Net::HTTP.get("https://status.com/ping") }
|
246
246
|
|
247
|
+
# ==> Shutdown callback
|
248
|
+
# When sidekiq process is shutting down, you can perform some action, like cleaning up created queue
|
249
|
+
# default: proc {}
|
250
|
+
#
|
251
|
+
# config.shutdown_callback = proc do
|
252
|
+
# Sidekiq::Queue.all.find { |q| q.name == "#{queue_prefix}-#{SidekiqAlive.hostname}" }&.clear
|
253
|
+
# end
|
254
|
+
|
247
255
|
# ==> Queue Prefix
|
248
256
|
# SidekiqAlive will run in a independent queue for each instance/replica
|
249
257
|
# This queue name will be generated with: "#{queue_prefix}-#{hostname}.
|
250
258
|
# You can customize the prefix here.
|
251
|
-
# default: :
|
259
|
+
# default: :sidekiq-alive
|
252
260
|
#
|
253
261
|
# config.queue_prefix = :other
|
254
262
|
|
data/lib/sidekiq_alive/config.rb
CHANGED
@@ -13,23 +13,26 @@ module SidekiqAlive
|
|
13
13
|
:registered_instance_key,
|
14
14
|
:queue_prefix,
|
15
15
|
:server,
|
16
|
-
:custom_liveness_probe
|
16
|
+
:custom_liveness_probe,
|
17
|
+
:logger,
|
18
|
+
:shutdown_callback
|
17
19
|
|
18
20
|
def initialize
|
19
21
|
set_defaults
|
20
22
|
end
|
21
23
|
|
22
24
|
def set_defaults
|
23
|
-
@host = ENV.fetch(
|
24
|
-
@port = ENV.fetch(
|
25
|
-
@path = ENV.fetch(
|
26
|
-
@liveness_key =
|
25
|
+
@host = ENV.fetch("SIDEKIQ_ALIVE_HOST", "0.0.0.0")
|
26
|
+
@port = ENV.fetch("SIDEKIQ_ALIVE_PORT", 7433)
|
27
|
+
@path = ENV.fetch("SIDEKIQ_ALIVE_PATH", "/")
|
28
|
+
@liveness_key = "SIDEKIQ::LIVENESS_PROBE_TIMESTAMP"
|
27
29
|
@time_to_live = 10 * 60
|
28
30
|
@callback = proc {}
|
29
|
-
@registered_instance_key =
|
30
|
-
@queue_prefix = :
|
31
|
-
@server = ENV.fetch(
|
31
|
+
@registered_instance_key = "SIDEKIQ_REGISTERED_INSTANCE"
|
32
|
+
@queue_prefix = :"sidekiq-alive"
|
33
|
+
@server = ENV.fetch("SIDEKIQ_ALIVE_SERVER", "webrick")
|
32
34
|
@custom_liveness_probe = proc { true }
|
35
|
+
@shutdown_callback = proc {}
|
33
36
|
end
|
34
37
|
|
35
38
|
def registration_ttl
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SidekiqAlive
|
4
|
+
module Helpers
|
5
|
+
class << self
|
6
|
+
def sidekiq_7
|
7
|
+
current_sidekiq_version >= Gem::Version.new("7")
|
8
|
+
end
|
9
|
+
|
10
|
+
def sidekiq_6
|
11
|
+
current_sidekiq_version >= Gem::Version.new("6") &&
|
12
|
+
current_sidekiq_version < Gem::Version.new("7")
|
13
|
+
end
|
14
|
+
|
15
|
+
def sidekiq_5
|
16
|
+
current_sidekiq_version >= Gem::Version.new("5") &&
|
17
|
+
current_sidekiq_version < Gem::Version.new("6")
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def current_sidekiq_version
|
23
|
+
Gem.loaded_specs["sidekiq"].version
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SidekiqAlive
|
4
|
+
module Redis
|
5
|
+
class Base
|
6
|
+
def set(key, time:, ex:)
|
7
|
+
raise("Implement me")
|
8
|
+
end
|
9
|
+
|
10
|
+
def match(key)
|
11
|
+
raise("Implement me")
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete(key)
|
15
|
+
raise("Implement me")
|
16
|
+
end
|
17
|
+
|
18
|
+
def ttl(...)
|
19
|
+
redis.ttl(...)
|
20
|
+
end
|
21
|
+
|
22
|
+
def flushall
|
23
|
+
redis.flushall
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def redis
|
29
|
+
Sidekiq.redis { |r| r }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
|
5
|
+
module SidekiqAlive
|
6
|
+
module Redis
|
7
|
+
# Wrapper for redis client used by sidekiq < 7
|
8
|
+
#
|
9
|
+
class Client < Base
|
10
|
+
def set(key, time:, ex:)
|
11
|
+
redis.set(key, time, ex: ex)
|
12
|
+
end
|
13
|
+
|
14
|
+
def match(key)
|
15
|
+
keys = []
|
16
|
+
cursor = 0
|
17
|
+
|
18
|
+
loop do
|
19
|
+
cursor, found_keys = redis.scan(cursor, match: key, count: 1000)
|
20
|
+
keys += found_keys if found_keys
|
21
|
+
break if cursor.to_i == 0
|
22
|
+
end
|
23
|
+
keys
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(key)
|
27
|
+
redis.del(key)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
|
5
|
+
module SidekiqAlive
|
6
|
+
module Redis
|
7
|
+
# Wrapper for redis client adapter used by sidekiq > 7
|
8
|
+
#
|
9
|
+
class ClientAdapter < Base
|
10
|
+
def set(key, time:, ex:)
|
11
|
+
redis.call("SET", key, time, ex: ex)
|
12
|
+
end
|
13
|
+
|
14
|
+
def match(key)
|
15
|
+
redis.scan("MATCH", key).map { |key| key }
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete(key)
|
19
|
+
redis.call("DEL", key)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/sidekiq_alive/server.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rack"
|
4
4
|
|
5
5
|
module SidekiqAlive
|
6
6
|
class Server
|
7
7
|
class << self
|
8
8
|
def run!
|
9
|
-
handler =
|
9
|
+
handler = Rack::Handler.get(server)
|
10
10
|
|
11
|
-
Signal.trap(
|
11
|
+
Signal.trap("TERM") { handler.shutdown }
|
12
12
|
|
13
13
|
handler.run(self, Port: port, Host: host, AccessLog: [], Logger: SidekiqAlive.logger)
|
14
14
|
end
|
@@ -31,9 +31,9 @@ module SidekiqAlive
|
|
31
31
|
|
32
32
|
def call(env)
|
33
33
|
if Rack::Request.new(env).path != path
|
34
|
-
[404, {}, [
|
34
|
+
[404, {}, ["Not found"]]
|
35
35
|
elsif SidekiqAlive.alive?
|
36
|
-
[200, {}, [
|
36
|
+
[200, {}, ["Alive!"]]
|
37
37
|
else
|
38
38
|
response = "Can't find the alive key"
|
39
39
|
SidekiqAlive.logger.error(response)
|
data/lib/sidekiq_alive.rb
CHANGED
@@ -1,168 +1,150 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq"
|
4
|
+
require "sidekiq/api"
|
5
|
+
require "singleton"
|
6
|
+
require "sidekiq_alive/version"
|
7
|
+
require "sidekiq_alive/config"
|
8
|
+
require "sidekiq_alive/helpers"
|
9
|
+
require "sidekiq_alive/redis/client"
|
10
|
+
require "sidekiq_alive/redis/client_adapter"
|
6
11
|
|
7
12
|
module SidekiqAlive
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
class << self
|
14
|
+
def start
|
15
|
+
Sidekiq.configure_server do |sq_config|
|
16
|
+
sq_config.on(:startup) do
|
17
|
+
SidekiqAlive::Worker.sidekiq_options(queue: current_queue)
|
18
|
+
if Helpers.sidekiq_7
|
19
|
+
sq_config.queues
|
20
|
+
else
|
21
|
+
sq_config.respond_to?(:[]) ? sq_config[:queues] : sq_config.options[:queues]
|
22
|
+
end.unshift(current_queue)
|
23
|
+
|
24
|
+
logger.info(startup_info)
|
25
|
+
|
26
|
+
register_current_instance
|
27
|
+
store_alive_key
|
28
|
+
SidekiqAlive::Worker.perform_async(hostname)
|
29
|
+
@server_pid = fork { SidekiqAlive::Server.run! }
|
30
|
+
|
31
|
+
logger.info(successful_startup_text)
|
24
32
|
end
|
25
|
-
end
|
26
33
|
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
sq_config.on(:quiet) do
|
35
|
+
unregister_current_instance
|
36
|
+
config.shutdown_callback.call
|
37
|
+
end
|
30
38
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
39
|
+
sq_config.on(:shutdown) do
|
40
|
+
Process.kill("TERM", @server_pid) unless @server_pid.nil?
|
41
|
+
Process.wait(@server_pid) unless @server_pid.nil?
|
42
|
+
|
43
|
+
unregister_current_instance
|
44
|
+
config.shutdown_callback.call
|
45
|
+
end
|
35
46
|
end
|
36
47
|
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.current_queue
|
40
|
-
"#{config.queue_prefix}-#{hostname}"
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.register_current_instance
|
44
|
-
register_instance(current_instance_register_key)
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.unregister_current_instance
|
48
|
-
# Delete any pending jobs for this instance
|
49
|
-
logger.info(shutdown_info)
|
50
|
-
purge_pending_jobs
|
51
|
-
redis.del(current_instance_register_key)
|
52
|
-
end
|
53
48
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.deep_scan(keyword, keys = [], cursor = 0)
|
59
|
-
loop do
|
60
|
-
cursor, found_keys = SidekiqAlive.redis.scan(cursor, match: keyword, count: 1000)
|
61
|
-
keys += found_keys if found_keys
|
62
|
-
break if cursor.to_i == 0
|
49
|
+
def current_queue
|
50
|
+
"#{config.queue_prefix}-#{hostname}"
|
63
51
|
end
|
64
|
-
keys
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.purge_pending_jobs
|
68
|
-
# TODO:
|
69
|
-
# Sidekiq 6 allows better way to find scheduled jobs:
|
70
|
-
# https://github.com/mperham/sidekiq/wiki/API#scan
|
71
|
-
scheduled_set = Sidekiq::ScheduledSet.new
|
72
|
-
jobs = scheduled_set.select { |job| job.klass == 'SidekiqAlive::Worker' && job.queue == current_queue }
|
73
|
-
logger.info("[SidekiqAlive] Purging #{jobs.count} pending for #{hostname}")
|
74
|
-
jobs.each(&:delete)
|
75
|
-
logger.info("[SidekiqAlive] Removing queue #{current_queue}")
|
76
|
-
Sidekiq::Queue.new(current_queue).clear
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.current_instance_register_key
|
80
|
-
"#{config.registered_instance_key}::#{hostname}"
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.store_alive_key
|
84
|
-
redis.set(current_lifeness_key,
|
85
|
-
Time.now.to_i,
|
86
|
-
ex: config.time_to_live.to_i)
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.redis
|
90
|
-
Sidekiq.redis { |r| r }
|
91
|
-
end
|
92
|
-
|
93
|
-
def self.alive?
|
94
|
-
redis.ttl(current_lifeness_key) != -2
|
95
|
-
end
|
96
52
|
|
97
|
-
|
53
|
+
def register_current_instance
|
54
|
+
register_instance(current_instance_register_key)
|
55
|
+
end
|
98
56
|
|
99
|
-
|
100
|
-
|
101
|
-
|
57
|
+
def unregister_current_instance
|
58
|
+
# Delete any pending jobs for this instance
|
59
|
+
logger.info(shutdown_info)
|
60
|
+
purge_pending_jobs
|
61
|
+
redis.delete(current_instance_register_key)
|
62
|
+
end
|
102
63
|
|
103
|
-
|
104
|
-
|
105
|
-
|
64
|
+
def registered_instances
|
65
|
+
redis.match("#{config.registered_instance_key}::*")
|
66
|
+
end
|
106
67
|
|
107
|
-
|
108
|
-
|
109
|
-
|
68
|
+
def purge_pending_jobs
|
69
|
+
schedule_set = Sidekiq::ScheduledSet.new
|
70
|
+
jobs = if Helpers.sidekiq_5
|
71
|
+
schedule_set.select { |job| job.klass == "SidekiqAlive::Worker" && job.queue == current_queue }
|
72
|
+
else
|
73
|
+
schedule_set.scan('"class":"SidekiqAlive::Worker"').select { |job| job.queue == current_queue }
|
74
|
+
end
|
75
|
+
logger.info("[SidekiqAlive] Purging #{jobs.count} pending for #{hostname}")
|
76
|
+
jobs.each(&:delete)
|
110
77
|
|
111
|
-
|
112
|
-
|
113
|
-
|
78
|
+
logger.info("[SidekiqAlive] Removing queue #{current_queue}")
|
79
|
+
Sidekiq::Queue.new(current_queue).clear
|
80
|
+
end
|
114
81
|
|
115
|
-
|
116
|
-
|
117
|
-
|
82
|
+
def current_instance_register_key
|
83
|
+
"#{config.registered_instance_key}::#{hostname}"
|
84
|
+
end
|
118
85
|
|
119
|
-
|
120
|
-
|
86
|
+
def store_alive_key
|
87
|
+
redis.set(current_lifeness_key, time: Time.now.to_i, ex: config.time_to_live.to_i)
|
88
|
+
end
|
121
89
|
|
122
|
-
|
90
|
+
def redis
|
91
|
+
@redis ||= Helpers.sidekiq_7 ? Redis::ClientAdapter.new : Redis::Client.new
|
92
|
+
end
|
123
93
|
|
124
|
-
|
125
|
-
|
126
|
-
|
94
|
+
def alive?
|
95
|
+
redis.ttl(current_lifeness_key) != -2
|
96
|
+
end
|
127
97
|
|
128
|
-
|
129
|
-
end
|
98
|
+
# CONFIG ---------------------------------------
|
130
99
|
|
131
|
-
|
132
|
-
|
100
|
+
def setup
|
101
|
+
yield(config)
|
102
|
+
end
|
133
103
|
|
134
|
-
|
104
|
+
def logger
|
105
|
+
config.logger || Sidekiq.logger
|
106
|
+
end
|
135
107
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
Time to live: #{config.time_to_live}s
|
140
|
-
Current instance register key: #{current_instance_register_key}
|
141
|
-
Worker running on queue: #{@queue}
|
108
|
+
def config
|
109
|
+
@config ||= SidekiqAlive::Config.instance
|
110
|
+
end
|
142
111
|
|
112
|
+
def current_lifeness_key
|
113
|
+
"#{config.liveness_key}::#{hostname}"
|
114
|
+
end
|
143
115
|
|
144
|
-
|
145
|
-
|
146
|
-
|
116
|
+
def hostname
|
117
|
+
ENV["HOSTNAME"] || "HOSTNAME_NOT_SET"
|
118
|
+
end
|
147
119
|
|
148
|
-
|
149
|
-
|
150
|
-
|
120
|
+
def shutdown_info
|
121
|
+
"Shutting down sidekiq-alive!"
|
122
|
+
end
|
151
123
|
|
152
|
-
|
124
|
+
def startup_info
|
125
|
+
info = {
|
126
|
+
hostname: hostname,
|
127
|
+
port: config.port,
|
128
|
+
ttl: config.time_to_live,
|
129
|
+
queue: current_queue,
|
130
|
+
liveness_key: current_lifeness_key,
|
131
|
+
register_key: current_instance_register_key,
|
132
|
+
}
|
133
|
+
|
134
|
+
"Starting sidekiq-alive: #{info}"
|
135
|
+
end
|
153
136
|
|
154
|
-
|
155
|
-
|
156
|
-
|
137
|
+
def successful_startup_text
|
138
|
+
"Successfully started sidekiq-alive, registered instances: #{registered_instances.join("\n\s\s- ")}"
|
139
|
+
end
|
157
140
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
ex: config.registration_ttl.to_i)
|
141
|
+
def register_instance(instance_name)
|
142
|
+
redis.set(instance_name, time: Time.now.to_i, ex: config.registration_ttl.to_i)
|
143
|
+
end
|
162
144
|
end
|
163
145
|
end
|
164
146
|
|
165
|
-
require
|
166
|
-
require
|
147
|
+
require "sidekiq_alive/worker"
|
148
|
+
require "sidekiq_alive/server"
|
167
149
|
|
168
|
-
SidekiqAlive.start unless ENV.fetch(
|
150
|
+
SidekiqAlive.start unless ENV.fetch("DISABLE_SIDEKIQ_ALIVE", "").casecmp("true").zero?
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_alive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Andrejs Cunskis
|
7
8
|
- Artur Pañach
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2023-01-11 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -25,33 +26,33 @@ dependencies:
|
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '1.16'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
+
name: debug
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - "
|
32
|
+
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
+
version: '1.6'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- - "
|
39
|
+
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
+
version: '1.6'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: rack-test
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - "
|
46
|
+
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
+
version: 2.0.2
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- - "
|
53
|
+
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
+
version: 2.0.2
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
57
|
name: rake
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,75 +95,126 @@ dependencies:
|
|
94
95
|
- - "~>"
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '3.0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rubocop-shopify
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '2.10'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.10'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: solargraph
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.48.0
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.48.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rack
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "<"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '3'
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "<"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '3'
|
97
140
|
- !ruby/object:Gem::Dependency
|
98
141
|
name: sidekiq
|
99
142
|
requirement: !ruby/object:Gem::Requirement
|
100
143
|
requirements:
|
101
144
|
- - ">="
|
102
145
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
146
|
+
version: '5'
|
147
|
+
- - "<"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '8'
|
104
150
|
type: :runtime
|
105
151
|
prerelease: false
|
106
152
|
version_requirements: !ruby/object:Gem::Requirement
|
107
153
|
requirements:
|
108
154
|
- - ">="
|
109
155
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
156
|
+
version: '5'
|
157
|
+
- - "<"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '8'
|
111
160
|
- !ruby/object:Gem::Dependency
|
112
161
|
name: webrick
|
113
162
|
requirement: !ruby/object:Gem::Requirement
|
114
163
|
requirements:
|
115
164
|
- - ">="
|
116
165
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
166
|
+
version: '1'
|
167
|
+
- - "<"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '2'
|
118
170
|
type: :runtime
|
119
171
|
prerelease: false
|
120
172
|
version_requirements: !ruby/object:Gem::Requirement
|
121
173
|
requirements:
|
122
174
|
- - ">="
|
123
175
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
125
|
-
|
176
|
+
version: '1'
|
177
|
+
- - "<"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '2'
|
180
|
+
description: |
|
126
181
|
SidekiqAlive offers a solution to add liveness probe of a Sidekiq instance.
|
127
182
|
|
128
|
-
|
183
|
+
How?
|
129
184
|
|
130
|
-
|
185
|
+
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.
|
131
186
|
|
132
|
-
|
133
|
-
|
187
|
+
A Sidekiq job is the responsable to storing this key. If Sidekiq stops processing jobs
|
188
|
+
this key gets expired by Redis an consequently the http server will return a 500 error.
|
134
189
|
|
135
|
-
|
190
|
+
This Job is responsible to requeue itself for the next liveness probe.
|
136
191
|
email:
|
192
|
+
- andrejs.cunskis@gmail.com
|
137
193
|
- arturictus@gmail.com
|
138
194
|
executables: []
|
139
195
|
extensions: []
|
140
196
|
extra_rdoc_files: []
|
141
197
|
files:
|
142
|
-
- ".github/workflows/test.yml"
|
143
|
-
- ".gitignore"
|
144
|
-
- ".rspec"
|
145
|
-
- ".tool-versions"
|
146
|
-
- CODE_OF_CONDUCT.md
|
147
|
-
- Gemfile
|
148
|
-
- Gemfile.lock
|
149
|
-
- LICENSE.txt
|
150
198
|
- README.md
|
151
|
-
- Rakefile
|
152
|
-
- bin/console
|
153
|
-
- bin/setup
|
154
|
-
- docker-compose.yml
|
155
199
|
- lib/sidekiq_alive.rb
|
156
200
|
- lib/sidekiq_alive/config.rb
|
201
|
+
- lib/sidekiq_alive/helpers.rb
|
202
|
+
- lib/sidekiq_alive/redis/base.rb
|
203
|
+
- lib/sidekiq_alive/redis/client.rb
|
204
|
+
- lib/sidekiq_alive/redis/client_adapter.rb
|
157
205
|
- lib/sidekiq_alive/server.rb
|
158
206
|
- lib/sidekiq_alive/version.rb
|
159
207
|
- lib/sidekiq_alive/worker.rb
|
160
|
-
- sidekiq_alive.gemspec
|
161
208
|
homepage: https://github.com/arturictus/sidekiq_alive
|
162
209
|
licenses:
|
163
210
|
- MIT
|
164
|
-
metadata:
|
165
|
-
|
211
|
+
metadata:
|
212
|
+
homepage_uri: https://github.com/arturictus/sidekiq_alive
|
213
|
+
source_code_uri: https://github.com/arturictus/sidekiq_alive
|
214
|
+
changelog_uri: https://github.com/arturictus/sidekiq_alive/releases
|
215
|
+
documentation_uri: https://github.com/arturictus/sidekiq_alive/blob/v2.1.9/README.md
|
216
|
+
bug_tracker_uri: https://github.com/arturictus/sidekiq_alive/issues
|
217
|
+
post_install_message:
|
166
218
|
rdoc_options: []
|
167
219
|
require_paths:
|
168
220
|
- lib
|
@@ -170,7 +222,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
222
|
requirements:
|
171
223
|
- - ">="
|
172
224
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
225
|
+
version: 2.7.0
|
174
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
227
|
requirements:
|
176
228
|
- - ">="
|
@@ -178,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
230
|
version: '0'
|
179
231
|
requirements: []
|
180
232
|
rubygems_version: 3.3.26
|
181
|
-
signing_key:
|
233
|
+
signing_key:
|
182
234
|
specification_version: 4
|
183
235
|
summary: Liveness probe for sidekiq on Kubernetes deployments.
|
184
236
|
test_files: []
|
data/.github/workflows/test.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
name: Ruby CI
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [main, master]
|
6
|
-
pull_request:
|
7
|
-
branches: [main, master]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
test:
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
|
13
|
-
strategy:
|
14
|
-
matrix:
|
15
|
-
ruby-version: ["3.1", "3.0", "2.7", "2.6", "2.5"]
|
16
|
-
# Service containers to run with `runner-job`
|
17
|
-
services:
|
18
|
-
# Label used to access the service container
|
19
|
-
redis:
|
20
|
-
# Docker Hub image
|
21
|
-
image: redis
|
22
|
-
# Set health checks to wait until redis has started
|
23
|
-
options: >-
|
24
|
-
--health-cmd "redis-cli ping"
|
25
|
-
--health-interval 10s
|
26
|
-
--health-timeout 5s
|
27
|
-
--health-retries 5
|
28
|
-
ports:
|
29
|
-
# Maps port 6379 on service container to the host
|
30
|
-
- 6379:6379
|
31
|
-
|
32
|
-
steps:
|
33
|
-
- uses: actions/checkout@v2
|
34
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
35
|
-
uses: ruby/setup-ruby@v1
|
36
|
-
with:
|
37
|
-
ruby-version: ${{ matrix.ruby-version }}
|
38
|
-
- name: Install dependencies
|
39
|
-
run: bundle install
|
40
|
-
- name: Run tests
|
41
|
-
run: bundle exec rspec
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.tool-versions
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby 3.1.3
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at arturictus@gmail.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: http://contributor-covenant.org
|
74
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
sidekiq_alive (2.1.7)
|
5
|
-
sidekiq
|
6
|
-
webrick
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
coderay (1.1.2)
|
12
|
-
connection_pool (2.2.5)
|
13
|
-
diff-lcs (1.3)
|
14
|
-
method_source (0.9.2)
|
15
|
-
mock_redis (0.19.0)
|
16
|
-
pry (0.12.2)
|
17
|
-
coderay (~> 1.1.0)
|
18
|
-
method_source (~> 0.9.0)
|
19
|
-
rack (2.2.3)
|
20
|
-
rack-test (1.1.0)
|
21
|
-
rack (>= 1.0, < 3)
|
22
|
-
rake (13.0.3)
|
23
|
-
redis (4.6.0)
|
24
|
-
rspec (3.8.0)
|
25
|
-
rspec-core (~> 3.8.0)
|
26
|
-
rspec-expectations (~> 3.8.0)
|
27
|
-
rspec-mocks (~> 3.8.0)
|
28
|
-
rspec-core (3.8.0)
|
29
|
-
rspec-support (~> 3.8.0)
|
30
|
-
rspec-expectations (3.8.2)
|
31
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.8.0)
|
33
|
-
rspec-mocks (3.8.0)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.8.0)
|
36
|
-
rspec-sidekiq (3.0.3)
|
37
|
-
rspec-core (~> 3.0, >= 3.0.0)
|
38
|
-
sidekiq (>= 2.4.0)
|
39
|
-
rspec-support (3.8.0)
|
40
|
-
sidekiq (6.4.1)
|
41
|
-
connection_pool (>= 2.2.2)
|
42
|
-
rack (~> 2.0)
|
43
|
-
redis (>= 4.2.0)
|
44
|
-
webrick (1.7.0)
|
45
|
-
|
46
|
-
PLATFORMS
|
47
|
-
ruby
|
48
|
-
|
49
|
-
DEPENDENCIES
|
50
|
-
bundler (> 1.16)
|
51
|
-
mock_redis
|
52
|
-
pry
|
53
|
-
rack-test
|
54
|
-
rake (~> 13.0)
|
55
|
-
rspec (~> 3.0)
|
56
|
-
rspec-sidekiq (~> 3.0)
|
57
|
-
sidekiq_alive!
|
58
|
-
|
59
|
-
BUNDLED WITH
|
60
|
-
2.2.22
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2018 Artur Pañach
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'sidekiq_alive'
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require 'irb'
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/docker-compose.yml
DELETED
data/sidekiq_alive.gemspec
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
lib = File.expand_path('lib', __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'sidekiq_alive/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = 'sidekiq_alive'
|
7
|
-
spec.version = SidekiqAlive::VERSION
|
8
|
-
spec.authors = ['Artur Pañach']
|
9
|
-
spec.email = ['arturictus@gmail.com']
|
10
|
-
|
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.
|
13
|
-
|
14
|
-
How?
|
15
|
-
|
16
|
-
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.
|
17
|
-
|
18
|
-
A Sidekiq job is the responsable to storing this key. If Sidekiq stops processing jobs
|
19
|
-
this key gets expired by Redis an consequently the http server will return a 500 error.
|
20
|
-
|
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'
|
24
|
-
|
25
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
-
f.match(%r{^(test|spec|features)/})
|
27
|
-
end
|
28
|
-
spec.bindir = 'exe'
|
29
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
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', '~> 13.0'
|
36
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
-
spec.add_development_dependency 'rspec-sidekiq', '~> 3.0'
|
38
|
-
spec.add_dependency 'sidekiq'
|
39
|
-
spec.add_dependency 'webrick'
|
40
|
-
end
|