sidekiq-alive-next 2.2.1 → 3.1.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 +6 -1
- data/lib/sidekiq-alive-next.rb +10 -21
- data/lib/sidekiq_alive/server.rb +2 -1
- data/lib/sidekiq_alive/version.rb +1 -1
- metadata +50 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a18bb6defb7f2d0d3eb1e1b01ce12b683c5c634be2e43b74600b787cdf4ae0e9
|
4
|
+
data.tar.gz: d0bb5d30eeee984dee67e75228d5d6ca3df91301eea805414dee6665dd058859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15cbeff2addefafddb0416fc194d5943d190bf03d1482b57a7b09771c72edaf015cee7ea55b23a055a775526b5a55b854c5251f27835839339e1d31a996f0523
|
7
|
+
data.tar.gz: 2c6e9f7aae03381045cc0b641b8caaff01ac6d8b51932f902e1578a6923e2ec62c4b1c4c6e9d6c54183a64fd56e0d2f766d26c99fd832f8c60b3fb5394f6babb
|
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# SidekiqAlive
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/sidekiq-alive-next.svg)](https://rubygems.org/gems/sidekiq-alive-next)
|
4
|
+
[![Total Downloads](https://img.shields.io/gem/dt/sidekiq-alive-next?color=blue)](https://rubygems.org/gems/https://rubygems.org/gems/sidekiq-alive-next)
|
5
|
+
![Workflow status](https://github.com/allure-framework/allure-ruby/workflows/Test/badge.svg)
|
6
|
+
[![Known Vulnerabilities](https://snyk.io/test/github/andrcuns/sidekiq-alive/badge.svg)](https://snyk.io/test/github/andrcuns/sidekiq-alive)
|
7
|
+
|
3
8
|
**This is the fork of 'arturictus/sidekiq_alive' with a few minor fixes and tweaks, all credit goes to author of original repo**
|
4
9
|
|
5
10
|
SidekiqAlive offers a solution to add liveness probe for a Sidekiq instance deployed in Kubernetes.
|
@@ -277,7 +282,7 @@ Here is an example [rails app](https://github.com/arturictus/sidekiq_alive_examp
|
|
277
282
|
|
278
283
|
## Contributing
|
279
284
|
|
280
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
285
|
+
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
286
|
|
282
287
|
## License
|
283
288
|
|
data/lib/sidekiq-alive-next.rb
CHANGED
@@ -14,7 +14,7 @@ module SidekiqAlive
|
|
14
14
|
Sidekiq.configure_server do |sq_config|
|
15
15
|
sq_config.on(:startup) do
|
16
16
|
SidekiqAlive::Worker.sidekiq_options(queue: current_queue)
|
17
|
-
|
17
|
+
sq_config.queues.unshift(current_queue)
|
18
18
|
|
19
19
|
logger.info(startup_info)
|
20
20
|
|
@@ -53,29 +53,18 @@ module SidekiqAlive
|
|
53
53
|
# Delete any pending jobs for this instance
|
54
54
|
logger.info(shutdown_info)
|
55
55
|
purge_pending_jobs
|
56
|
-
redis.
|
56
|
+
redis.call("DEL", current_instance_register_key)
|
57
57
|
end
|
58
58
|
|
59
59
|
def registered_instances
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def deep_scan(keyword, keys = [], cursor = 0)
|
64
|
-
loop do
|
65
|
-
cursor, found_keys = SidekiqAlive.redis.scan(cursor, match: keyword, count: 1000)
|
66
|
-
keys += found_keys
|
67
|
-
break if cursor.to_i.zero?
|
68
|
-
end
|
69
|
-
keys
|
60
|
+
redis.scan("MATCH", "#{config.registered_instance_key}::*").map { |key| key }
|
70
61
|
end
|
71
62
|
|
72
63
|
def purge_pending_jobs
|
73
|
-
|
74
|
-
# https://github.com/mperham/sidekiq/wiki/API#scan
|
75
|
-
scheduled_set = Sidekiq::ScheduledSet.new
|
76
|
-
jobs = scheduled_set.select { |job| job.klass == "SidekiqAlive::Worker" && job.queue == current_queue }
|
64
|
+
jobs = Sidekiq::ScheduledSet.new.scan('"class":"SidekiqAlive::Worker"')
|
77
65
|
logger.info("[SidekiqAlive] Purging #{jobs.count} pending for #{hostname}")
|
78
66
|
jobs.each(&:delete)
|
67
|
+
|
79
68
|
logger.info("[SidekiqAlive] Removing queue #{current_queue}")
|
80
69
|
Sidekiq::Queue.new(current_queue).clear
|
81
70
|
end
|
@@ -85,9 +74,7 @@ module SidekiqAlive
|
|
85
74
|
end
|
86
75
|
|
87
76
|
def store_alive_key
|
88
|
-
redis.
|
89
|
-
Time.now.to_i,
|
90
|
-
ex: config.time_to_live.to_i)
|
77
|
+
redis.call("SET", current_lifeness_key, Time.now.to_i, ex: config.time_to_live.to_i)
|
91
78
|
end
|
92
79
|
|
93
80
|
def redis
|
@@ -130,6 +117,8 @@ module SidekiqAlive
|
|
130
117
|
port: config.port,
|
131
118
|
ttl: config.time_to_live,
|
132
119
|
queue: current_queue,
|
120
|
+
liveness_key: current_lifeness_key,
|
121
|
+
register_key: current_instance_register_key,
|
133
122
|
}
|
134
123
|
|
135
124
|
"Starting sidekiq-alive: #{info}"
|
@@ -140,9 +129,9 @@ module SidekiqAlive
|
|
140
129
|
end
|
141
130
|
|
142
131
|
def register_instance(instance_name)
|
143
|
-
redis.
|
132
|
+
redis.call("SET", instance_name, Time.now.to_i, ex: config.registration_ttl.to_i)
|
144
133
|
end
|
145
|
-
end
|
134
|
+
end
|
146
135
|
end
|
147
136
|
|
148
137
|
require "sidekiq_alive/worker"
|
data/lib/sidekiq_alive/server.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rack"
|
4
|
+
require "rackup"
|
4
5
|
|
5
6
|
module SidekiqAlive
|
6
7
|
class Server
|
7
8
|
class << self
|
8
9
|
def run!
|
9
|
-
handler =
|
10
|
+
handler = Rackup::Handler.get(server)
|
10
11
|
|
11
12
|
Signal.trap("TERM") { handler.shutdown }
|
12
13
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-alive-next
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrejs Cunskis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -26,33 +26,33 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.16'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: debug
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '1.6'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '1.6'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rack-test
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 2.0.2
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 2.0.2
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,25 +124,59 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 0.47.2
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: rack
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '
|
132
|
+
version: '3'
|
133
133
|
- - "<"
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: '
|
135
|
+
version: '4'
|
136
|
+
type: :runtime
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '3'
|
143
|
+
- - "<"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '4'
|
146
|
+
- !ruby/object:Gem::Dependency
|
147
|
+
name: rackup
|
148
|
+
requirement: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.2.2
|
136
153
|
type: :runtime
|
137
154
|
prerelease: false
|
138
155
|
version_requirements: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.2.2
|
160
|
+
- !ruby/object:Gem::Dependency
|
161
|
+
name: sidekiq
|
162
|
+
requirement: !ruby/object:Gem::Requirement
|
139
163
|
requirements:
|
140
164
|
- - ">="
|
141
165
|
- !ruby/object:Gem::Version
|
142
|
-
version: '
|
166
|
+
version: '7'
|
143
167
|
- - "<"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '8'
|
170
|
+
type: :runtime
|
171
|
+
prerelease: false
|
172
|
+
version_requirements: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
144
175
|
- !ruby/object:Gem::Version
|
145
176
|
version: '7'
|
177
|
+
- - "<"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '8'
|
146
180
|
- !ruby/object:Gem::Dependency
|
147
181
|
name: webrick
|
148
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +227,7 @@ metadata:
|
|
193
227
|
homepage_uri: https://github.com/andrcuns/sidekiq-alive
|
194
228
|
source_code_uri: https://github.com/andrcuns/sidekiq-alive
|
195
229
|
changelog_uri: https://github.com/andrcuns/sidekiq-alive/releases
|
196
|
-
documentation_uri: https://github.com/andrcuns/sidekiq-alive/blob/
|
230
|
+
documentation_uri: https://github.com/andrcuns/sidekiq-alive/blob/v3.1.0/README.md
|
197
231
|
bug_tracker_uri: https://github.com/andrcuns/sidekiq-alive/issues
|
198
232
|
post_install_message:
|
199
233
|
rdoc_options: []
|