puma-status 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/core.rb +6 -1
  3. data/lib/stats.rb +15 -3
  4. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a3510db7ca511e5f6a661691bc2126aa17de54ceedbaa9dc308c2d7e215c6bd
4
- data.tar.gz: 1a3e97ac2ac36cf2fdfb1113aa961523e9912be90842dd9e534689e489718536
3
+ metadata.gz: f327ff6c023bad34b7c01a219db11210cebad0bf54406a128968217603021fec
4
+ data.tar.gz: e5cf7266ef9680ca884ff82614a9855738a368acb1702b2dc79a1ed3bcadb8bd
5
5
  SHA512:
6
- metadata.gz: 2a63842da6fb0657826c7caba586a018f56983865999e4c9576af6f2d02a965367091450086f27a6e52bfdb07e2409dbd7723be3b384e7899cf3cc714607f63f
7
- data.tar.gz: 027417e5cd61121b0b1293caeeee0332d2f269fbc33a386566832963e1e53be1939a42c7815bdf56711210cef466b30bd0bd45c1b3713bc6d3a43107afc0ff4d
6
+ metadata.gz: 1e483270e101d60a19402fbab29ee6165fbc1db1c5a7920a857e2a90611f7f09f0dddf366a3aedbc83d9d933af085ae823502491f8444d44501d8d8a63beed0c
7
+ data.tar.gz: 173715cae769db0f9d58ca25c4eb7c64a3fc96d203824eef9f2620d16a2483105273f9e7a3176bc9684d37b73a8a46993708833b870ed2e08f02c7279e1ef1a0
data/lib/core.rb CHANGED
@@ -43,12 +43,17 @@ def hydrate_stats(stats, puma_state, state_file_path)
43
43
  end
44
44
 
45
45
  def display_stats(stats)
46
- puts "#{stats.pid} (#{stats.state_file_path}) Uptime: #{seconds_to_human(stats.uptime)} | Load: #{color(75, 50, stats.load, asciiThreadLoad(stats.running_threads, stats.total_threads))}"
46
+ master_line = "#{stats.pid} (#{stats.state_file_path}) Uptime: #{seconds_to_human(stats.uptime)} "
47
+ master_line += "| Phase: #{stats.phase} " if stats.phase
48
+ master_line += "| Load: #{color(75, 50, stats.load, asciiThreadLoad(stats.running_threads, stats.total_threads))}"
49
+
50
+ puts master_line
47
51
 
48
52
  stats.workers.each do |wstats|
49
53
  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.total_threads))}"
50
54
  worker_line += " #{("Queue: " + wstats.backlog.to_s).colorize(:red)}" if wstats.backlog > 0
51
55
  worker_line += " Last checkin: #{wstats.last_checkin}" if wstats.last_checkin >= 10
56
+ worker_line += " Phase: #{wstats.phase}" if wstats.phase != stats.phase
52
57
 
53
58
  puts worker_line
54
59
  end
data/lib/stats.rb CHANGED
@@ -30,12 +30,20 @@ class Stats
30
30
  end
31
31
  alias :total_threads :running
32
32
 
33
+ def max_threads
34
+ @wstats.dig('last_status', 'max_threads') || @wstats['max_threads'] || 0
35
+ end
36
+
33
37
  def pool_capacity
34
38
  @wstats.dig('last_status', 'pool_capacity') || @wstats['pool_capacity'] || 0
35
39
  end
36
40
 
37
41
  def running_threads
38
- running - pool_capacity
42
+ max_threads - pool_capacity
43
+ end
44
+
45
+ def phase
46
+ @wstats['phase']
39
47
  end
40
48
 
41
49
  def load
@@ -88,11 +96,11 @@ class Stats
88
96
  end
89
97
 
90
98
  def total_threads
91
- workers.reduce(0) { |total, wstats| total + wstats.running }
99
+ workers.reduce(0) { |total, wstats| total + wstats.max_threads }
92
100
  end
93
101
 
94
102
  def running_threads
95
- workers.reduce(0) { |total, wstats| total + (wstats.running - wstats.pool_capacity) }
103
+ workers.reduce(0) { |total, wstats| total + wstats.running_threads }
96
104
  end
97
105
 
98
106
  def running
@@ -103,6 +111,10 @@ class Stats
103
111
  @stats['pool_capacity'] || 0
104
112
  end
105
113
 
114
+ def phase
115
+ @stats['phase']
116
+ end
117
+
106
118
  def load
107
119
  running_threads/total_threads.to_f*100
108
120
  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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoann Lecuyer
@@ -112,9 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.7.6.2
115
+ rubygems_version: 3.0.3
117
116
  signing_key:
118
117
  specification_version: 4
119
- summary: Command-line too for puma to display information about running request/process
118
+ summary: Command-line tool for puma to display information about running request/process
120
119
  test_files: []