sidekiq-err 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 540a25393182c06c16aa1133a3eb97a382a4e7918d37564ab48ea1f5244b3bad
4
- data.tar.gz: 1780bcba830dc7332e999381ade9e86f0480d4386727aef14f7f680ea1e0efd6
3
+ metadata.gz: ead219be46df36a1507a4c648fe192447617080adb2457b9e1db85a4943012a5
4
+ data.tar.gz: eca16de0c52782b7ad768712d1a2e31482fa37e1e2cf3904f720b74be3da5b38
5
5
  SHA512:
6
- metadata.gz: 0d40784c25269602e7b9698583f27a0cc0a6c760693bc0947a5a816789b4a29ee79dc16fe6d5e8598a5efd090e84aba1123c3ea5080681664a9e76e7469d5418
7
- data.tar.gz: 12b25794cdb14be82e0a048037596d897764f3b56bb2b875904cd8909c1266f67f9475725fbecae9bf2ca7bf0aa4d584fcc9caa06c6c30b78cddba74f033cd6a
6
+ metadata.gz: 8085e4bc38a2db6f3bb4c0f661e11ba747b920054d3b9e2a4278d510fc89bb599e1f366cf391a87643cda5215141f9f132ce75aa1dfc5ef638e2c1eab4686854
7
+ data.tar.gz: ed89f1e4284f1c8b2a8898549875b9a58cfb300081a473c8a2d111d72cac522176ea8bb3cfb9a241dd6815f5fcc6e3a4cef0a7b6fdd32840b228edcc4ef84766
data/exe/sidekiq-err CHANGED
@@ -10,7 +10,13 @@ require 'pry' if ENV.fetch('USE_PRY', false)
10
10
  begin
11
11
  case ARGV[0]
12
12
  when '-a', '--alive'
13
- SidekiqErr.alive?
13
+ if ARGV[1]
14
+ SidekiqErr.alive?(ARGV[1])
15
+ else
16
+ puts
17
+ puts 'Missing hostname argument, use --help for usage details'
18
+ puts
19
+ end
14
20
  when '-r', '--report'
15
21
  SidekiqErr.status(ARGV[1])
16
22
  when '-h', '--help'
@@ -2,9 +2,21 @@
2
2
 
3
3
  module SidekiqErr
4
4
  class Alive
5
- def self.check?
5
+ def self.check?(hostname)
6
6
  process_set = Sidekiq::ProcessSet.new
7
- raise(NoProcessFound, 'No sidekiq process running!') if process_set.size.zero?
7
+ # now search for the provided process name in the process set
8
+ found_process = process_set.find do |process|
9
+ # we compare the process hostname here as we can know this from k8s land pod
10
+ # and can use the $HOSTNAME env var in the probe command in the probe specification
11
+ #
12
+ # https://stackoverflow.com/questions/58800495/get-a-kubernetes-pods-full-id-from-inside-of-itself-running-container
13
+ # Note: this aligns to 1 sidekiq container process per pod
14
+ # this may not hold true in some deployments but should work for most use cases
15
+ # it's preferable to use pod auto scaling vs running multiple containers in a pod
16
+ process['hostname'] == hostname
17
+ end
18
+
19
+ raise(NoProcessFound, "No sidekiq process found for hostname: #{hostname}") unless found_process
8
20
  end
9
21
  end
10
22
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqErr
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/sidekiq-err.rb CHANGED
@@ -15,9 +15,9 @@ module SidekiqErr
15
15
  puts
16
16
  puts "Usage: #{CMD}"
17
17
  puts
18
- puts ' -a, --alive'
19
- puts ' check if at least 1 Sidekiq process is running'
20
- puts ' sets the exit code to 1 if no process if found'
18
+ puts ' -a, --alive HOSTNAME'
19
+ puts ' check if the HOSTNAME is present in the Sidekiq process list'
20
+ puts ' sets the exit code to 1 if the HOSTNAME process is not found'
21
21
  puts
22
22
  puts ' -r, --report [SECTION_NAME]'
23
23
  puts ' view the status report'
@@ -32,7 +32,7 @@ module SidekiqErr
32
32
  SidekiqErr::View.new(section).display
33
33
  end
34
34
 
35
- def self.alive?
36
- SidekiqErr::Alive.check?
35
+ def self.alive?(hostname)
36
+ SidekiqErr::Alive.check?(hostname)
37
37
  end
38
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-err
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Campbell Allen