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 +4 -4
- data/exe/sidekiq-err +7 -1
- data/lib/sidekiq-err/alive.rb +14 -2
- data/lib/sidekiq-err/version.rb +1 -1
- data/lib/sidekiq-err.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ead219be46df36a1507a4c648fe192447617080adb2457b9e1db85a4943012a5
|
|
4
|
+
data.tar.gz: eca16de0c52782b7ad768712d1a2e31482fa37e1e2cf3904f720b74be3da5b38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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'
|
data/lib/sidekiq-err/alive.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
data/lib/sidekiq-err/version.rb
CHANGED
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
|
|
20
|
-
puts ' sets the exit code to 1 if
|
|
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
|