sidekiq-alive-next 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/sidekiq-alive-next.rb +112 -116
- data/lib/sidekiq_alive/config.rb +6 -6
- data/lib/sidekiq_alive/server.rb +5 -5
- data/lib/sidekiq_alive/version.rb +1 -1
- metadata +72 -49
- data/.github/dependabot.yml +0 -16
- data/.github/release.yml +0 -23
- data/.github/workflows/release.yml +0 -40
- data/.github/workflows/test.yml +0 -45
- data/.gitignore +0 -12
- data/.rspec +0 -4
- data/.ruby-version +0 -1
- data/.tool-versions +0 -1
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -64
- 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: b348a1daf1eb508fcd8c171d454451f40552c1a30696edaaecb956cdc270f601
|
4
|
+
data.tar.gz: 30f55c866378f828c52ea5255bc667d04fa23fc3f7f7a33a332848ba72be972b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fafd8efa2b7cb77093d8d9c79bf793612534eb12c2c342e519a96adf851f8bdf2bae155887b54409cc8af40e99fdc17141b783365630956e3f41e4c571873a18
|
7
|
+
data.tar.gz: a29b9cf9035f589d23859faf270523c125c6f80c7ef77d60cd77d4c497113698eaee74df0c81071f6527a05d870d1a260a3ddb2421f4befa1299b6ac02ed906e
|
data/README.md
CHANGED
@@ -277,7 +277,7 @@ Here is an example [rails app](https://github.com/arturictus/sidekiq_alive_examp
|
|
277
277
|
|
278
278
|
## Contributing
|
279
279
|
|
280
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
280
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/andrcuns/sidekiq-alive. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
281
281
|
|
282
282
|
## License
|
283
283
|
|
data/lib/sidekiq-alive-next.rb
CHANGED
@@ -1,146 +1,142 @@
|
|
1
|
-
|
2
|
-
require 'sidekiq/api'
|
3
|
-
require 'singleton'
|
4
|
-
require 'sidekiq_alive/version'
|
5
|
-
require 'sidekiq_alive/config'
|
1
|
+
# rubocop:disable Naming/FileName
|
6
2
|
|
7
|
-
|
8
|
-
def self.start
|
9
|
-
Sidekiq.configure_server do |sq_config|
|
10
|
-
sq_config.on(:startup) do
|
11
|
-
SidekiqAlive::Worker.sidekiq_options queue: current_queue
|
12
|
-
(sq_config.respond_to?(:[]) ? sq_config[:queues] : sq_config.options[:queues]).unshift(current_queue)
|
13
|
-
|
14
|
-
logger.info(startup_info)
|
15
|
-
|
16
|
-
register_current_instance
|
17
|
-
store_alive_key
|
18
|
-
SidekiqAlive::Worker.perform_async(hostname)
|
19
|
-
@server_pid = fork { SidekiqAlive::Server.run! }
|
20
|
-
|
21
|
-
logger.info(successful_startup_text)
|
22
|
-
end
|
23
|
-
|
24
|
-
sq_config.on(:quiet) do
|
25
|
-
unregister_current_instance
|
26
|
-
config.shutdown_callback.call
|
27
|
-
end
|
3
|
+
# frozen_string_literal: true
|
28
4
|
|
29
|
-
|
30
|
-
|
31
|
-
|
5
|
+
require "sidekiq"
|
6
|
+
require "sidekiq/api"
|
7
|
+
require "singleton"
|
8
|
+
require "sidekiq_alive/version"
|
9
|
+
require "sidekiq_alive/config"
|
32
10
|
|
33
|
-
|
34
|
-
|
11
|
+
module SidekiqAlive
|
12
|
+
class << self
|
13
|
+
def start
|
14
|
+
Sidekiq.configure_server do |sq_config|
|
15
|
+
sq_config.on(:startup) do
|
16
|
+
SidekiqAlive::Worker.sidekiq_options(queue: current_queue)
|
17
|
+
sq_config.queues.unshift(current_queue)
|
18
|
+
|
19
|
+
logger.info(startup_info)
|
20
|
+
|
21
|
+
register_current_instance
|
22
|
+
store_alive_key
|
23
|
+
SidekiqAlive::Worker.perform_async(hostname)
|
24
|
+
@server_pid = fork { SidekiqAlive::Server.run! }
|
25
|
+
|
26
|
+
logger.info(successful_startup_text)
|
27
|
+
end
|
28
|
+
|
29
|
+
sq_config.on(:quiet) do
|
30
|
+
unregister_current_instance
|
31
|
+
config.shutdown_callback.call
|
32
|
+
end
|
33
|
+
|
34
|
+
sq_config.on(:shutdown) do
|
35
|
+
Process.kill("TERM", @server_pid) unless @server_pid.nil?
|
36
|
+
Process.wait(@server_pid) unless @server_pid.nil?
|
37
|
+
|
38
|
+
unregister_current_instance
|
39
|
+
config.shutdown_callback.call
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
37
|
-
end
|
38
43
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
def self.register_current_instance
|
44
|
-
register_instance(current_instance_register_key)
|
45
|
-
end
|
44
|
+
def current_queue
|
45
|
+
"#{config.queue_prefix}-#{hostname}"
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
purge_pending_jobs
|
51
|
-
redis.del(current_instance_register_key)
|
52
|
-
end
|
48
|
+
def register_current_instance
|
49
|
+
register_instance(current_instance_register_key)
|
50
|
+
end
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
def unregister_current_instance
|
53
|
+
# Delete any pending jobs for this instance
|
54
|
+
logger.info(shutdown_info)
|
55
|
+
purge_pending_jobs
|
56
|
+
redis.call("DEL", current_instance_register_key)
|
57
|
+
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
cursor, found_keys = SidekiqAlive.redis.scan(cursor, match: keyword, count: 1000)
|
61
|
-
keys += found_keys
|
62
|
-
break if cursor.to_i.zero?
|
59
|
+
def registered_instances
|
60
|
+
redis.scan("MATCH", "#{config.registered_instance_key}::*").map { |key| key }
|
63
61
|
end
|
64
|
-
keys
|
65
|
-
end
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
63
|
+
def purge_pending_jobs
|
64
|
+
jobs = Sidekiq::ScheduledSet.new.scan('"class":"SidekiqAlive::Worker"')
|
65
|
+
logger.info("[SidekiqAlive] Purging #{jobs.count} pending for #{hostname}")
|
66
|
+
jobs.each(&:delete)
|
78
67
|
|
79
|
-
|
80
|
-
|
81
|
-
|
68
|
+
logger.info("[SidekiqAlive] Removing queue #{current_queue}")
|
69
|
+
Sidekiq::Queue.new(current_queue).clear
|
70
|
+
end
|
82
71
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
ex: config.time_to_live.to_i)
|
87
|
-
end
|
72
|
+
def current_instance_register_key
|
73
|
+
"#{config.registered_instance_key}::#{hostname}"
|
74
|
+
end
|
88
75
|
|
89
|
-
|
90
|
-
|
91
|
-
|
76
|
+
def store_alive_key
|
77
|
+
redis.call("SET", current_lifeness_key, Time.now.to_i, ex: config.time_to_live.to_i)
|
78
|
+
end
|
92
79
|
|
93
|
-
|
94
|
-
|
95
|
-
|
80
|
+
def redis
|
81
|
+
Sidekiq.redis { |r| r }
|
82
|
+
end
|
96
83
|
|
97
|
-
|
84
|
+
def alive?
|
85
|
+
redis.ttl(current_lifeness_key) != -2
|
86
|
+
end
|
98
87
|
|
99
|
-
|
100
|
-
yield(config)
|
101
|
-
end
|
88
|
+
# CONFIG ---------------------------------------
|
102
89
|
|
103
|
-
|
104
|
-
|
105
|
-
|
90
|
+
def setup
|
91
|
+
yield(config)
|
92
|
+
end
|
106
93
|
|
107
|
-
|
108
|
-
|
109
|
-
|
94
|
+
def logger
|
95
|
+
config.logger || Sidekiq.logger
|
96
|
+
end
|
110
97
|
|
111
|
-
|
112
|
-
|
113
|
-
|
98
|
+
def config
|
99
|
+
@config ||= SidekiqAlive::Config.instance
|
100
|
+
end
|
114
101
|
|
115
|
-
|
116
|
-
|
117
|
-
|
102
|
+
def current_lifeness_key
|
103
|
+
"#{config.liveness_key}::#{hostname}"
|
104
|
+
end
|
118
105
|
|
119
|
-
|
120
|
-
|
121
|
-
|
106
|
+
def hostname
|
107
|
+
ENV["HOSTNAME"] || "HOSTNAME_NOT_SET"
|
108
|
+
end
|
122
109
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
port: config.port,
|
127
|
-
ttl: config.time_to_live,
|
128
|
-
queue: current_queue
|
129
|
-
}
|
110
|
+
def shutdown_info
|
111
|
+
"Shutting down sidekiq-alive!"
|
112
|
+
end
|
130
113
|
|
131
|
-
|
132
|
-
|
114
|
+
def startup_info
|
115
|
+
info = {
|
116
|
+
hostname: hostname,
|
117
|
+
port: config.port,
|
118
|
+
ttl: config.time_to_live,
|
119
|
+
queue: current_queue,
|
120
|
+
liveness_key: current_lifeness_key,
|
121
|
+
register_key: current_instance_register_key,
|
122
|
+
}
|
123
|
+
|
124
|
+
"Starting sidekiq-alive: #{info}"
|
125
|
+
end
|
133
126
|
|
134
|
-
|
135
|
-
|
136
|
-
|
127
|
+
def successful_startup_text
|
128
|
+
"Successfully started sidekiq-alive, registered instances: #{registered_instances.join("\n\s\s- ")}"
|
129
|
+
end
|
137
130
|
|
138
|
-
|
139
|
-
|
131
|
+
def register_instance(instance_name)
|
132
|
+
redis.call("SET", instance_name, Time.now.to_i, ex: config.registration_ttl.to_i)
|
133
|
+
end
|
140
134
|
end
|
141
135
|
end
|
142
136
|
|
143
|
-
require
|
144
|
-
require
|
137
|
+
require "sidekiq_alive/worker"
|
138
|
+
require "sidekiq_alive/server"
|
139
|
+
|
140
|
+
SidekiqAlive.start unless ENV.fetch("DISABLE_SIDEKIQ_ALIVE", "").casecmp("true").zero?
|
145
141
|
|
146
|
-
|
142
|
+
# rubocop:enable Naming/FileName
|
data/lib/sidekiq_alive/config.rb
CHANGED
@@ -22,15 +22,15 @@ module SidekiqAlive
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def set_defaults
|
25
|
-
@host = ENV.fetch(
|
26
|
-
@port = ENV.fetch(
|
27
|
-
@path = ENV.fetch(
|
28
|
-
@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"
|
29
29
|
@time_to_live = 10 * 60
|
30
30
|
@callback = proc {}
|
31
|
-
@registered_instance_key =
|
31
|
+
@registered_instance_key = "SIDEKIQ_REGISTERED_INSTANCE"
|
32
32
|
@queue_prefix = :"sidekiq-alive"
|
33
|
-
@server = ENV.fetch(
|
33
|
+
@server = ENV.fetch("SIDEKIQ_ALIVE_SERVER", "webrick")
|
34
34
|
@custom_liveness_probe = proc { true }
|
35
35
|
@shutdown_callback = proc {}
|
36
36
|
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)
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-alive-next
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrejs Cunskis
|
8
|
+
- Artur Pañach
|
8
9
|
autorequire:
|
9
|
-
bindir:
|
10
|
+
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
12
|
+
date: 2022-10-29 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -25,49 +26,49 @@ dependencies:
|
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '1.16'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
+
name: rack-test
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - "
|
32
|
+
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
+
version: 2.0.2
|
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: 2.0.2
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
+
name: rake
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - "
|
46
|
+
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
+
version: '13.0'
|
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: '0'
|
55
|
+
version: '13.0'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
+
name: rspec
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
60
|
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
+
version: '3.0'
|
62
63
|
type: :development
|
63
64
|
prerelease: false
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
+
version: '3.0'
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
+
name: rspec-sidekiq
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
74
|
- - "~>"
|
@@ -81,39 +82,73 @@ dependencies:
|
|
81
82
|
- !ruby/object:Gem::Version
|
82
83
|
version: '3.0'
|
83
84
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
+
name: rubocop-shopify
|
85
86
|
requirement: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
88
|
- - "~>"
|
88
89
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
+
version: '2.10'
|
90
91
|
type: :development
|
91
92
|
prerelease: false
|
92
93
|
version_requirements: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
95
|
- - "~>"
|
95
96
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
97
|
+
version: '2.10'
|
97
98
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
99
|
+
name: solargraph
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.47.2
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 0.47.2
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rack
|
99
114
|
requirement: !ruby/object:Gem::Requirement
|
100
115
|
requirements:
|
101
116
|
- - ">="
|
102
117
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
118
|
+
version: 2.2.4
|
104
119
|
- - "<"
|
105
120
|
- !ruby/object:Gem::Version
|
106
|
-
version: '
|
121
|
+
version: '3'
|
107
122
|
type: :runtime
|
108
123
|
prerelease: false
|
109
124
|
version_requirements: !ruby/object:Gem::Requirement
|
110
125
|
requirements:
|
111
126
|
- - ">="
|
112
127
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
128
|
+
version: 2.2.4
|
114
129
|
- - "<"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3'
|
132
|
+
- !ruby/object:Gem::Dependency
|
133
|
+
name: sidekiq
|
134
|
+
requirement: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
115
137
|
- !ruby/object:Gem::Version
|
116
138
|
version: '7'
|
139
|
+
- - "<"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '8'
|
142
|
+
type: :runtime
|
143
|
+
prerelease: false
|
144
|
+
version_requirements: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '7'
|
149
|
+
- - "<"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '8'
|
117
152
|
- !ruby/object:Gem::Dependency
|
118
153
|
name: webrick
|
119
154
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,50 +169,38 @@ dependencies:
|
|
134
169
|
- - "<"
|
135
170
|
- !ruby/object:Gem::Version
|
136
171
|
version: '2'
|
137
|
-
description:
|
172
|
+
description: |
|
138
173
|
SidekiqAlive offers a solution to add liveness probe of a Sidekiq instance.
|
139
174
|
|
140
|
-
|
175
|
+
How?
|
141
176
|
|
142
|
-
|
177
|
+
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.
|
143
178
|
|
144
|
-
|
145
|
-
|
179
|
+
A Sidekiq job is the responsable to storing this key. If Sidekiq stops processing jobs
|
180
|
+
this key gets expired by Redis an consequently the http server will return a 500 error.
|
146
181
|
|
147
|
-
|
182
|
+
This Job is responsible to requeue itself for the next liveness probe.
|
148
183
|
email:
|
149
184
|
- andrejs.cunskis@gmail.com
|
150
185
|
executables: []
|
151
186
|
extensions: []
|
152
187
|
extra_rdoc_files: []
|
153
188
|
files:
|
154
|
-
- ".github/dependabot.yml"
|
155
|
-
- ".github/release.yml"
|
156
|
-
- ".github/workflows/release.yml"
|
157
|
-
- ".github/workflows/test.yml"
|
158
|
-
- ".gitignore"
|
159
|
-
- ".rspec"
|
160
|
-
- ".ruby-version"
|
161
|
-
- ".tool-versions"
|
162
|
-
- CODE_OF_CONDUCT.md
|
163
|
-
- Gemfile
|
164
|
-
- Gemfile.lock
|
165
|
-
- LICENSE.txt
|
166
189
|
- README.md
|
167
|
-
- Rakefile
|
168
|
-
- bin/console
|
169
|
-
- bin/setup
|
170
|
-
- docker-compose.yml
|
171
190
|
- lib/sidekiq-alive-next.rb
|
172
191
|
- lib/sidekiq_alive/config.rb
|
173
192
|
- lib/sidekiq_alive/server.rb
|
174
193
|
- lib/sidekiq_alive/version.rb
|
175
194
|
- lib/sidekiq_alive/worker.rb
|
176
|
-
- sidekiq_alive.gemspec
|
177
195
|
homepage: https://github.com/andrcuns/sidekiq-alive
|
178
196
|
licenses:
|
179
197
|
- MIT
|
180
|
-
metadata:
|
198
|
+
metadata:
|
199
|
+
homepage_uri: https://github.com/andrcuns/sidekiq-alive
|
200
|
+
source_code_uri: https://github.com/andrcuns/sidekiq-alive
|
201
|
+
changelog_uri: https://github.com/andrcuns/sidekiq-alive/releases
|
202
|
+
documentation_uri: https://github.com/andrcuns/sidekiq-alive/blob/v3.0.0/README.md
|
203
|
+
bug_tracker_uri: https://github.com/andrcuns/sidekiq-alive/issues
|
181
204
|
post_install_message:
|
182
205
|
rdoc_options: []
|
183
206
|
require_paths:
|
@@ -186,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
209
|
requirements:
|
187
210
|
- - ">="
|
188
211
|
- !ruby/object:Gem::Version
|
189
|
-
version:
|
212
|
+
version: 2.7.0
|
190
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
214
|
requirements:
|
192
215
|
- - ">="
|
data/.github/dependabot.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
version: 2
|
2
|
-
updates:
|
3
|
-
- package-ecosystem: "bundler"
|
4
|
-
directory: "/"
|
5
|
-
schedule:
|
6
|
-
interval: "daily"
|
7
|
-
reviewers:
|
8
|
-
- "andrcuns"
|
9
|
-
- package-ecosystem: github-actions
|
10
|
-
directory: "/"
|
11
|
-
schedule:
|
12
|
-
interval: "daily"
|
13
|
-
reviewers:
|
14
|
-
- andrcuns
|
15
|
-
labels:
|
16
|
-
- "ci"
|
data/.github/release.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
changelog:
|
2
|
-
categories:
|
3
|
-
- title: '🚀 New Features'
|
4
|
-
labels:
|
5
|
-
- 'feature'
|
6
|
-
- title: '🔬 Improvements'
|
7
|
-
labels:
|
8
|
-
- 'enhancement'
|
9
|
-
- title: '🐞 Bug Fixes'
|
10
|
-
labels:
|
11
|
-
- 'bug'
|
12
|
-
- title: '📦 Dependency updates'
|
13
|
-
labels:
|
14
|
-
- 'dependencies'
|
15
|
-
- title: '📄 Documentation updates'
|
16
|
-
labels:
|
17
|
-
- 'documentation'
|
18
|
-
- title: '🧰 Maintenance'
|
19
|
-
labels:
|
20
|
-
- 'maintenance'
|
21
|
-
- title: '👷 CI'
|
22
|
-
labels:
|
23
|
-
- 'ci'
|
@@ -1,40 +0,0 @@
|
|
1
|
-
name: Release
|
2
|
-
|
3
|
-
on: workflow_dispatch
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
release:
|
7
|
-
name: Ruby gem
|
8
|
-
runs-on: ubuntu-latest
|
9
|
-
steps:
|
10
|
-
-
|
11
|
-
name: Checkout
|
12
|
-
uses: actions/checkout@v3
|
13
|
-
-
|
14
|
-
name: Set up Ruby 3.1
|
15
|
-
uses: ruby/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: 3.1.2
|
18
|
-
bundler-cache: true
|
19
|
-
-
|
20
|
-
name: Create tag and push to rubygems
|
21
|
-
run: |
|
22
|
-
git config user.name github-actions
|
23
|
-
git config user.email github-actions@github.com
|
24
|
-
bundle exec rake release
|
25
|
-
env:
|
26
|
-
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
|
27
|
-
|
28
|
-
gh-release:
|
29
|
-
name: Github release
|
30
|
-
runs-on: ubuntu-latest
|
31
|
-
needs: release
|
32
|
-
steps:
|
33
|
-
-
|
34
|
-
name: Checkout
|
35
|
-
uses: actions/checkout@v3
|
36
|
-
-
|
37
|
-
uses: softprops/action-gh-release@v1
|
38
|
-
with:
|
39
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
40
|
-
generate_release_notes: true
|
data/.github/workflows/test.yml
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
name: Test
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches:
|
6
|
-
- master
|
7
|
-
pull_request:
|
8
|
-
branches:
|
9
|
-
- master
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
test:
|
13
|
-
runs-on: ubuntu-latest
|
14
|
-
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby-version: ["3.1", "3.0", "2.7"]
|
19
|
-
# Service containers to run with `runner-job`
|
20
|
-
services:
|
21
|
-
# Label used to access the service container
|
22
|
-
redis:
|
23
|
-
# Docker Hub image
|
24
|
-
image: redis
|
25
|
-
# Set health checks to wait until redis has started
|
26
|
-
options: >-
|
27
|
-
--health-cmd "redis-cli ping"
|
28
|
-
--health-interval 10s
|
29
|
-
--health-timeout 5s
|
30
|
-
--health-retries 5
|
31
|
-
ports:
|
32
|
-
# Maps port 6379 on service container to the host
|
33
|
-
- 6379:6379
|
34
|
-
|
35
|
-
steps:
|
36
|
-
- uses: actions/checkout@v3
|
37
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
38
|
-
uses: ruby/setup-ruby@v1
|
39
|
-
with:
|
40
|
-
ruby-version: ${{ matrix.ruby-version }}
|
41
|
-
bundler-cache: true
|
42
|
-
- name: Install dependencies
|
43
|
-
run: bundle install
|
44
|
-
- name: Run tests
|
45
|
-
run: bundle exec rspec --color
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.0.4
|
data/.tool-versions
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby 3.0.4
|
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,64 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
sidekiq-alive-next (2.2.0)
|
5
|
-
sidekiq (>= 5, < 7)
|
6
|
-
webrick (>= 1, < 2)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
coderay (1.1.3)
|
12
|
-
connection_pool (2.3.0)
|
13
|
-
diff-lcs (1.5.0)
|
14
|
-
method_source (1.0.0)
|
15
|
-
mock_redis (0.34.0)
|
16
|
-
ruby2_keywords
|
17
|
-
pry (0.14.1)
|
18
|
-
coderay (~> 1.1)
|
19
|
-
method_source (~> 1.0)
|
20
|
-
rack (2.2.4)
|
21
|
-
rack-test (2.0.2)
|
22
|
-
rack (>= 1.3)
|
23
|
-
rake (13.0.6)
|
24
|
-
redis (4.8.0)
|
25
|
-
rspec (3.11.0)
|
26
|
-
rspec-core (~> 3.11.0)
|
27
|
-
rspec-expectations (~> 3.11.0)
|
28
|
-
rspec-mocks (~> 3.11.0)
|
29
|
-
rspec-core (3.11.0)
|
30
|
-
rspec-support (~> 3.11.0)
|
31
|
-
rspec-expectations (3.11.1)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.11.0)
|
34
|
-
rspec-mocks (3.11.1)
|
35
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
-
rspec-support (~> 3.11.0)
|
37
|
-
rspec-sidekiq (3.1.0)
|
38
|
-
rspec-core (~> 3.0, >= 3.0.0)
|
39
|
-
sidekiq (>= 2.4.0)
|
40
|
-
rspec-support (3.11.1)
|
41
|
-
ruby2_keywords (0.0.5)
|
42
|
-
sidekiq (6.5.7)
|
43
|
-
connection_pool (>= 2.2.5)
|
44
|
-
rack (~> 2.0)
|
45
|
-
redis (>= 4.5.0, < 5)
|
46
|
-
webrick (1.7.0)
|
47
|
-
|
48
|
-
PLATFORMS
|
49
|
-
aarch64-linux
|
50
|
-
arm64-darwin-21
|
51
|
-
x86_64-linux
|
52
|
-
|
53
|
-
DEPENDENCIES
|
54
|
-
bundler (> 1.16)
|
55
|
-
mock_redis
|
56
|
-
pry
|
57
|
-
rack-test
|
58
|
-
rake (~> 13.0)
|
59
|
-
rspec (~> 3.0)
|
60
|
-
rspec-sidekiq (~> 3.0)
|
61
|
-
sidekiq-alive-next!
|
62
|
-
|
63
|
-
BUNDLED WITH
|
64
|
-
2.3.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-next'
|
7
|
-
spec.version = SidekiqAlive::VERSION
|
8
|
-
spec.authors = ['Andrejs Cunskis']
|
9
|
-
spec.email = ['andrejs.cunskis@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/andrcuns/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', '>= 5', '< 7'
|
39
|
-
spec.add_dependency 'webrick', '>= 1', '< 2'
|
40
|
-
end
|