puma-status 0.1.5 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/core.rb +5 -6
- data/lib/helpers.rb +14 -3
- data/lib/puma-status.rb +24 -3
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46a19b27c114c23f83f652c395c9157d2581a0c688a42c2784c3660bef0f3277
|
4
|
+
data.tar.gz: 94a7a2cbee9aa0a082ddc38b61a32a4d2db3c3f8ad44a70b546a67b4a884dde8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b70ede2ef3c33c2436efe7da75faa5e858c5042572d07d26204487ea61a60d31cd2f9497502a5f8ae00bf00ecbdae0ac5ea6bceba1bfeec28036e9e18dc39c
|
7
|
+
data.tar.gz: f930e67b9deff2945d5f3a02c5635caf808b17a927527e533a3b7894e7b91ac59670c114c6fbb066a3be325fc9a78dc62cbfad12d26020a8e588b2a152d5e436
|
data/lib/core.rb
CHANGED
@@ -42,19 +42,18 @@ def hydrate_stats(stats, puma_state, state_file_path)
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def format_stats(stats)
|
46
46
|
master_line = "#{stats.pid} (#{stats.state_file_path}) Uptime: #{seconds_to_human(stats.uptime)} "
|
47
47
|
master_line += "| Phase: #{stats.phase} " if stats.phase
|
48
48
|
master_line += "| Load: #{color(75, 50, stats.load, asciiThreadLoad(stats.running_threads, stats.max_threads))}"
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
stats.workers.each do |wstats|
|
50
|
+
output = [master_line] + stats.workers.map do |wstats|
|
53
51
|
worker_line = " └ #{wstats.pid.to_s.rjust(5, ' ')} CPU: #{color(75, 50, wstats.pcpu, wstats.pcpu.to_s.rjust(5, ' '))}% Mem: #{color(1000, 750, wstats.mem, wstats.mem.to_s.rjust(4, ' '))} MB Uptime: #{seconds_to_human(wstats.uptime)} | Load: #{color(75, 50, wstats.load, asciiThreadLoad(wstats.running_threads, wstats.max_threads))}"
|
54
52
|
worker_line += " #{("Queue: " + wstats.backlog.to_s).colorize(:red)}" if wstats.backlog > 0
|
55
53
|
worker_line += " Last checkin: #{wstats.last_checkin}" if wstats.last_checkin >= 10
|
56
54
|
worker_line += " Phase: #{wstats.phase}" if wstats.phase != stats.phase
|
57
|
-
|
58
|
-
puts worker_line
|
55
|
+
worker_line
|
59
56
|
end
|
57
|
+
|
58
|
+
output.join("\n")
|
60
59
|
end
|
data/lib/helpers.rb
CHANGED
@@ -4,17 +4,28 @@ def debug(str)
|
|
4
4
|
puts str if ENV.key?('DEBUG')
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
7
|
+
def warn(str)
|
8
|
+
colorize(str, :yellow)
|
9
|
+
end
|
10
|
+
|
11
|
+
def error(str)
|
12
|
+
colorize(str, :red)
|
13
|
+
end
|
14
|
+
|
15
|
+
def colorize(str, color_name)
|
8
16
|
return str if ENV.key?('NO_COLOR')
|
17
|
+
str.to_s.colorize(color_name)
|
18
|
+
end
|
9
19
|
|
10
|
-
|
20
|
+
def color(critical, warn, value, str)
|
21
|
+
color_level = if value >= critical
|
11
22
|
:red
|
12
23
|
elsif value < critical && value >= warn
|
13
24
|
:yellow
|
14
25
|
else
|
15
26
|
:green
|
16
27
|
end
|
17
|
-
|
28
|
+
colorize(str, color_level)
|
18
29
|
end
|
19
30
|
|
20
31
|
def asciiThreadLoad(idx, total)
|
data/lib/puma-status.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative './helpers'
|
2
2
|
require_relative './core.rb'
|
3
|
+
require 'parallel'
|
3
4
|
|
4
5
|
def run
|
5
6
|
debug "puma-status"
|
@@ -10,8 +11,28 @@ def run
|
|
10
11
|
exit -1
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
errors = []
|
15
|
+
|
16
|
+
outputs = Parallel.map(ARGV, in_threads: ARGV.count) do |state_file_path|
|
17
|
+
begin
|
18
|
+
debug "State file: #{state_file_path}"
|
19
|
+
format_stats(get_stats(state_file_path))
|
20
|
+
rescue Errno::ENOENT
|
21
|
+
errors << "#{warn(state_file_path)} doesn't exists"
|
22
|
+
nil
|
23
|
+
rescue Errno::EISDIR
|
24
|
+
errors << "#{warn(state_file_path)} isn't a state file"
|
25
|
+
nil
|
26
|
+
rescue => e
|
27
|
+
errors << "#{error(state_file_path)} an unhandled error occured: #{e.inspect}"
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
outputs.compact.each { |output| puts output }
|
33
|
+
|
34
|
+
if errors.any?
|
35
|
+
puts ""
|
36
|
+
errors.each { |error| puts error }
|
16
37
|
end
|
17
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoann Lecuyer
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: parallel
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,15 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
119
|
requirements:
|
106
120
|
- - ">="
|
107
121
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
122
|
+
version: 2.3.0
|
109
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
124
|
requirements:
|
111
125
|
- - ">="
|
112
126
|
- !ruby/object:Gem::Version
|
113
127
|
version: '0'
|
114
128
|
requirements: []
|
115
|
-
|
116
|
-
rubygems_version: 2.7.6
|
129
|
+
rubygems_version: 3.1.2
|
117
130
|
signing_key:
|
118
131
|
specification_version: 4
|
119
132
|
summary: Command-line tool for puma to display information about running request/process
|