sidekiq_alive 1.0.1 → 1.1.0

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: 06606c5196a6ec3d6f8740b17dd23aa898bc3ba8bdc382a931b34092c3973d5b
4
- data.tar.gz: a9ad27ca8677547016c95ce459b61e3eabe2fc5a60479a7cff599504c1015050
3
+ metadata.gz: 788fbb3fc817ea121b46363271bcd0f1b814688a92082febf0ccd7432195c03c
4
+ data.tar.gz: 6065782d4680efe3c35695b06ef5ca748ef55942c7c0548b8e77fc4a1b413bbb
5
5
  SHA512:
6
- metadata.gz: 53342403bd87d484fc32b92d7019bd65aea5fdc6ab7e760c7dcaaae418846cc0d0c66aa6eb6a420546c2d18a14e15cbdfbfa605ddfd6ffa4c9e49141b0c21a8d
7
- data.tar.gz: 906c0644472d5f1e1fa13c52a727b3753f0a7216b77eec73a5351989a3dc730fe767f226b8c17759b6b6b3b2a496a52c709eab36b235c25042283f2a285b458f
6
+ metadata.gz: c388b1aeffd3967a2c126d9f0a6c1b823ac7ff05eff2d5adbb7900342ffa493fd312cf872888da2753484a8d7b9b84461b44ca500c94412d6d6df5906b011207
7
+ data.tar.gz: c06b9d7cac1f92dfcadb02493190003034fdb3b2144ea7c9d2793b5d1773b07be50804c56ad401f46cd73f0c3af16879ef5e670223816282a25fececeaab695f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sidekiq_alive (1.0.0)
4
+ sidekiq_alive (1.1.0)
5
5
  sidekiq
6
6
  sinatra
7
7
 
@@ -49,7 +49,7 @@ GEM
49
49
  rack (~> 1.5)
50
50
  rack-protection (~> 1.4)
51
51
  tilt (>= 1.3, < 3)
52
- tilt (2.0.8)
52
+ tilt (2.0.9)
53
53
 
54
54
  PLATFORMS
55
55
  ruby
@@ -65,4 +65,4 @@ DEPENDENCIES
65
65
  sidekiq_alive!
66
66
 
67
67
  BUNDLED WITH
68
- 1.16.4
68
+ 1.17.1
data/README.md CHANGED
@@ -11,10 +11,10 @@ __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 job is the responsable to storing this key. If Sidekiq stops processing jobs
14
+ A Sidekiq worker is the responsable 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
- This Job is responsible to requeue itself for the next liveness probe.
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
 
@@ -35,6 +35,26 @@ Or install it yourself as:
35
35
 
36
36
  $ gem install sidekiq_alive
37
37
 
38
+ Run `Sidekiq` with a `sidekiq_alive` queue.
39
+
40
+ ```
41
+ sidekiq -q sidekiq_alive
42
+ ```
43
+
44
+ or in your config:
45
+
46
+ _sidekiq.yml_
47
+ ```yaml
48
+ queues:
49
+ - default
50
+ - sidekiq_alive
51
+ ```
52
+
53
+ __IMPORTANT:__
54
+
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)
57
+
38
58
  ## Usage
39
59
 
40
60
  SidekiqAlive will start when running `sidekiq` command.
@@ -135,6 +155,18 @@ SidekiqAlive.setup do |config|
135
155
  #
136
156
  # require 'net/http'
137
157
  # config.callback = proc { Net::HTTP.get("https://status.com/ping") }
158
+
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!!
167
+ # default: :sidekiq_alive
168
+ #
169
+ # config.preferred_queue = :other
138
170
  end
139
171
  ```
140
172
 
@@ -144,6 +176,8 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
144
176
 
145
177
  To install this gem onto your local machine, run `bundle exec rake install`.
146
178
 
179
+ Here is a example [rails app](https://github.com/arturictus/sidekiq_alive_example)
180
+
147
181
  ## Contributing
148
182
 
149
183
  Bug reports and pull requests are welcome on GitHub at https://github.com/arturictus/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.
@@ -6,7 +6,8 @@ module SidekiqAlive
6
6
  :liveness_key,
7
7
  :time_to_live,
8
8
  :callback,
9
- :registered_instance_key
9
+ :registered_instance_key,
10
+ :preferred_queue
10
11
 
11
12
  def initialize
12
13
  set_defaults
@@ -18,6 +19,7 @@ module SidekiqAlive
18
19
  @time_to_live = 10 * 60
19
20
  @callback = proc {}
20
21
  @registered_instance_key = "SIDEKIQ_REGISTERED_INSTANCE"
22
+ @preferred_queue = :sidekiq_alive
21
23
  end
22
24
 
23
25
  end
@@ -1,3 +1,3 @@
1
1
  module SidekiqAlive
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/sidekiq_alive.rb CHANGED
@@ -6,6 +6,9 @@ require "sidekiq_alive/config"
6
6
  module SidekiqAlive
7
7
  def self.start
8
8
  Sidekiq.configure_server do |config|
9
+
10
+ SidekiqAlive::Worker.sidekiq_options queue: SidekiqAlive.select_queue(config.options[:queues])
11
+
9
12
  config.on(:startup) do
10
13
  SidekiqAlive.tap do |sa|
11
14
  sa.logger.info(banner)
@@ -16,6 +19,7 @@ module SidekiqAlive
16
19
  sa.logger.info(successful_startup_text)
17
20
  end
18
21
  end
22
+
19
23
  config.on(:quiet) do
20
24
  SidekiqAlive.unregister_current_instance
21
25
  end
@@ -26,6 +30,14 @@ module SidekiqAlive
26
30
 
27
31
  end
28
32
 
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
+ end
40
+
29
41
  def self.register_current_instance
30
42
  register_instance(current_instance_register_key)
31
43
  end
@@ -88,6 +100,8 @@ module SidekiqAlive
88
100
  Port: #{config.port}
89
101
  Time to live: #{config.time_to_live}s
90
102
  Current instance register key: #{current_instance_register_key}
103
+ Worker running on queue: #{@queue}
104
+
91
105
 
92
106
  starting ...
93
107
  BANNER
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.0.1
4
+ version: 1.1.0
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-01-08 00:00:00.000000000 Z
11
+ date: 2019-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler