puma-status 1.2 → 1.3

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/core.rb +2 -2
  3. data/lib/helpers.rb +8 -3
  4. data/lib/stats.rb +6 -0
  5. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec73cc842d7b353e3f3994d554c4fdc6b1b7eab51452c578581d855610af613d
4
- data.tar.gz: 6d44df05c3a303e3440406146921f4955a85fbded8ae131b29f1fec83f56b8fa
3
+ metadata.gz: ded7bd0b4bca01b8b07ca16c7380453cf96f49d0c00667d024a6317d7307cea0
4
+ data.tar.gz: a391f836ca1c5d1a40acbab75178fd4c569d25005fac3c83bfd981051e1a7d66
5
5
  SHA512:
6
- metadata.gz: ab70d17e5b5c35bacce07819392f2818f62020287d7070618af64fa58e1da9f71fe7de126f60d2886a29c2d13d6e31698f071784f6f98c9c5773a7ee934e16b6
7
- data.tar.gz: 41a1df505a6bb1299973a8972522b700d16b9d40232f567e237b20ce637de89733a72e7eae4944dcd0950c0c7b13a755353fbca601da55dc4d56167b5b2f8a66
6
+ metadata.gz: c3968446849e0078c9cb557c721a1f5a2226a5ca1533016b319d15ec4c2e769a88062c8f354de28451fad533ba6502707a79660bf9a0469c677482f270ab1c65
7
+ data.tar.gz: e186aefc643f0ce7bfaf9515d5a36fc71558c0a871d792914e55e5867d5d0d9e4e32d04a71f27429ab1ae19f43054d06ae00c47911f209bcf423c197e4c586b6
data/lib/core.rb CHANGED
@@ -82,7 +82,7 @@ def format_stats(stats)
82
82
  if stats.booting?
83
83
  master_line += " #{warn("booting")}"
84
84
  else
85
- master_line += " | Load: #{color(75, 50, stats.load, asciiThreadLoad(stats.running_threads, stats.max_threads))}"
85
+ master_line += " | Load: #{color(75, 50, stats.load, asciiThreadLoad(stats.running_threads, stats.spawned_threads, stats.max_threads))}"
86
86
  master_line += " | Req: #{stats.requests_count}" if stats.requests_count
87
87
  end
88
88
 
@@ -94,7 +94,7 @@ def format_stats(stats)
94
94
  elsif wstats.killed?
95
95
  worker_line += " #{error("killed")}"
96
96
  else
97
- worker_line += " | Load: #{color(75, 50, wstats.load, asciiThreadLoad(wstats.running_threads, wstats.max_threads))}"
97
+ worker_line += " | Load: #{color(75, 50, wstats.load, asciiThreadLoad(wstats.running_threads, wstats.spawned_threads, wstats.max_threads))}"
98
98
  worker_line += " | Phase: #{error(wstats.phase)}" if wstats.phase != stats.phase
99
99
  worker_line += " | Req: #{wstats.requests_count}" if wstats.requests_count
100
100
  worker_line += " Queue: #{error(wstats.backlog.to_s)}" if wstats.backlog > 0
data/lib/helpers.rb CHANGED
@@ -29,11 +29,16 @@ def color(critical, warn, value, str = nil)
29
29
  colorize(str, color_level)
30
30
  end
31
31
 
32
- def asciiThreadLoad(idx, total)
32
+ def asciiThreadLoad(running, spawned, total)
33
33
  full = "█"
34
- empty= "░"
34
+ half= "░"
35
+ empty = " "
35
36
 
36
- "#{idx}[#{full*idx}#{empty*(total-idx)}]#{total}"
37
+ full_count = running
38
+ half_count = [spawned - running, 0].max
39
+ empty_count = total - half_count - full_count
40
+
41
+ "#{running}[#{full*full_count}#{half*half_count}#{empty*empty_count}]#{total}"
37
42
  end
38
43
 
39
44
  def seconds_to_human(seconds)
data/lib/stats.rb CHANGED
@@ -41,10 +41,12 @@ class Stats
41
41
  @wstats.dig('last_status', 'running') || @wstats['running'] || 0
42
42
  end
43
43
  alias :total_threads :running
44
+ alias :spawned_threads :running
44
45
 
45
46
  def max_threads
46
47
  @wstats.dig('last_status', 'max_threads') || @wstats['max_threads'] || 0
47
48
  end
49
+ alias :total_threads :max_threads
48
50
 
49
51
  def pool_capacity
50
52
  @wstats.dig('last_status', 'pool_capacity') || @wstats['pool_capacity'] || 0
@@ -123,6 +125,10 @@ class Stats
123
125
  workers.reduce(0) { |total, wstats| total + wstats.running_threads }
124
126
  end
125
127
 
128
+ def spawned_threads
129
+ workers.reduce(0) { |total, wstats| total + wstats.spawned_threads }
130
+ end
131
+
126
132
  def max_threads
127
133
  workers.reduce(0) { |total, wstats| total + wstats.max_threads }
128
134
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-status
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoann Lecuyer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2019-07-14 00:00:00.000000000 Z
@@ -94,8 +94,8 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.9'
97
- description:
98
- email:
97
+ description:
98
+ email:
99
99
  executables:
100
100
  - puma-status
101
101
  extensions: []
@@ -111,7 +111,7 @@ homepage: https://github.com/ylecuyer/puma-status
111
111
  licenses:
112
112
  - MIT
113
113
  metadata: {}
114
- post_install_message:
114
+ post_install_message:
115
115
  rdoc_options: []
116
116
  require_paths:
117
117
  - lib
@@ -126,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.2.3
130
- signing_key:
129
+ rubygems_version: 3.3.0.dev
130
+ signing_key:
131
131
  specification_version: 4
132
132
  summary: Command-line tool for puma to display information about running request/process
133
133
  test_files: []