sidekiq_alive 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -11
- data/README.md +14 -6
- data/lib/sidekiq_alive.rb +1 -0
- data/lib/sidekiq_alive/config.rb +2 -0
- data/lib/sidekiq_alive/server.rb +34 -15
- data/lib/sidekiq_alive/version.rb +1 -1
- data/sidekiq_alive.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3bef9746bd43d32416e55a9f5b8bf719498ae3daa6c50bb018bddecbc49234c
|
4
|
+
data.tar.gz: 7f1cb14b61f71af4a4e15437e0395413d9861b86d3a3cf214c0bf5a88dc7e98a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61789b71b9a1819e38f69763348c06af301f3ac7fb0e4164728a4802db3846700b97aff2b78dec75f44df71b1f230b9d79fff7234d14989639cad50e90ab3347
|
7
|
+
data.tar.gz: 2b6e99585bbd51e205a09b16786eeae165b9657c7aa1683fca0feb8c15c20b49b67e83a413ac9960b6f3ae19a44d74480220b52535c9893c9a3ee7ad092b4434
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sidekiq_alive (2.0.
|
4
|
+
sidekiq_alive (2.0.3)
|
5
5
|
sidekiq
|
6
|
-
sinatra
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
@@ -13,8 +12,6 @@ GEM
|
|
13
12
|
diff-lcs (1.3)
|
14
13
|
method_source (0.9.2)
|
15
14
|
mock_redis (0.19.0)
|
16
|
-
mustermann (1.1.1)
|
17
|
-
ruby2_keywords (~> 0.0.1)
|
18
15
|
pry (0.12.2)
|
19
16
|
coderay (~> 1.1.0)
|
20
17
|
method_source (~> 0.9.0)
|
@@ -41,18 +38,11 @@ GEM
|
|
41
38
|
rspec-core (~> 3.0, >= 3.0.0)
|
42
39
|
sidekiq (>= 2.4.0)
|
43
40
|
rspec-support (3.8.0)
|
44
|
-
ruby2_keywords (0.0.2)
|
45
41
|
sidekiq (5.2.5)
|
46
42
|
connection_pool (~> 2.2, >= 2.2.2)
|
47
43
|
rack (>= 1.5.0)
|
48
44
|
rack-protection (>= 1.5.0)
|
49
45
|
redis (>= 3.3.5, < 5)
|
50
|
-
sinatra (2.0.5)
|
51
|
-
mustermann (~> 1.0)
|
52
|
-
rack (~> 2.0)
|
53
|
-
rack-protection (= 2.0.5)
|
54
|
-
tilt (~> 2.0)
|
55
|
-
tilt (2.0.10)
|
56
46
|
|
57
47
|
PLATFORMS
|
58
48
|
ruby
|
data/README.md
CHANGED
@@ -65,7 +65,7 @@ bundle exec sidekiq
|
|
65
65
|
|
66
66
|
```
|
67
67
|
curl localhost:7433
|
68
|
-
#=> Alive!
|
68
|
+
#=> Alive!
|
69
69
|
```
|
70
70
|
|
71
71
|
|
@@ -197,11 +197,19 @@ curl localhost:7433
|
|
197
197
|
```ruby
|
198
198
|
SidekiqAlive.setup do |config|
|
199
199
|
# ==> Server port
|
200
|
-
# Port to bind the server
|
200
|
+
# Port to bind the server.
|
201
|
+
# Can also be set with the environment variable SIDEKIQ_ALIVE_PORT.
|
201
202
|
# default: 7433
|
202
203
|
#
|
203
204
|
# config.port = 7433
|
204
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
|
+
|
205
213
|
# ==> Liveness key
|
206
214
|
# Key to be stored in Redis as probe of liveness
|
207
215
|
# default: "SIDEKIQ::LIVENESS_PROBE_TIMESTAMP"
|
@@ -233,11 +241,11 @@ SidekiqAlive.setup do |config|
|
|
233
241
|
# config.queue_prefix = :other
|
234
242
|
|
235
243
|
# ==> Rack server
|
236
|
-
# Web server used to
|
237
|
-
#
|
244
|
+
# Web server used to serve an HTTP response.
|
245
|
+
# Can also be set with the environment variable SIDEKIQ_ALIVE_SERVER.
|
246
|
+
# default: 'webrick'
|
238
247
|
#
|
239
|
-
#
|
240
|
-
|
248
|
+
# config.server = 'puma'
|
241
249
|
end
|
242
250
|
```
|
243
251
|
|
data/lib/sidekiq_alive.rb
CHANGED
data/lib/sidekiq_alive/config.rb
CHANGED
@@ -5,6 +5,7 @@ module SidekiqAlive
|
|
5
5
|
include Singleton
|
6
6
|
|
7
7
|
attr_accessor :port,
|
8
|
+
:path,
|
8
9
|
:liveness_key,
|
9
10
|
:time_to_live,
|
10
11
|
:callback,
|
@@ -18,6 +19,7 @@ module SidekiqAlive
|
|
18
19
|
|
19
20
|
def set_defaults
|
20
21
|
@port = ENV['SIDEKIQ_ALIVE_PORT'] || 7433
|
22
|
+
@path = ENV['SIDEKIQ_ALIVE_PATH'] || '/'
|
21
23
|
@liveness_key = 'SIDEKIQ::LIVENESS_PROBE_TIMESTAMP'
|
22
24
|
@time_to_live = 10 * 60
|
23
25
|
@callback = proc {}
|
data/lib/sidekiq_alive/server.rb
CHANGED
@@ -1,21 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'rack'
|
4
|
+
|
4
5
|
module SidekiqAlive
|
5
|
-
class Server
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
SidekiqAlive.
|
17
|
-
|
18
|
-
|
6
|
+
class Server
|
7
|
+
class << self
|
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')
|
14
|
+
end
|
15
|
+
|
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
|
26
|
+
end
|
27
|
+
|
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
|
19
38
|
end
|
20
39
|
end
|
21
40
|
end
|
data/sidekiq_alive.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_alive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
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: 2020-
|
11
|
+
date: 2020-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: sinatra
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
111
|
description: |-
|
126
112
|
SidekiqAlive offers a solution to add liveness probe of a Sidekiq instance.
|
127
113
|
|