puma-status 0.2.1 → 1.0

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 +7 -5
  3. data/lib/stats.rb +10 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 379b1ab081684ba19977385c0bad2d6b1635d9fd56225a35b89698574281c832
4
- data.tar.gz: 1e8db9d9acbe9a74e850c5ff214bd8258a5c6d748e1e662367003297c40d185a
3
+ metadata.gz: 2f95a656741b1b1aafddb43954a144399db944b78ca6384e9ec77cc0783ca750
4
+ data.tar.gz: a1b2f9addd173d84404bb94e26ec38522586d72fca0e190562d86d9a3e95b92a
5
5
  SHA512:
6
- metadata.gz: 8f2f695e9b510c2dd0f3eb6f808e927dae5a596a69d1e7d8347617c6590e09d0c299c2f66f63574fe95da971fe85c780cea407da2ade8a5eb443230ebbdc22ff
7
- data.tar.gz: d618f0c0bc28f4fdf6720b3e595269670967185bacbb5c754fde0e6bf863d37dbe5bb12692099bb25f15a46a634894b494a5bb5dba6c649a5771653862d8567d
6
+ metadata.gz: a44a39a95544ba5a9cd42b4e87ac2409a5b0c3623dad6af622c7a589be755c91ab26af03daf7a7304d2ba0da8e9a216a6a850dd5409e7f75d8eee2e5a6c79a23
7
+ data.tar.gz: a344489b4164ff044ff37ac39b4cfaab7a9f4ea74fe2c1cc12a6c124d3804a94260423c2be8ca12d02b42f30754a30f630de8bf93cd723a12385a6b7dad211a6
data/lib/core.rb CHANGED
@@ -59,13 +59,14 @@ def hydrate_stats(stats, puma_state, state_file_path)
59
59
  end
60
60
 
61
61
  def format_stats(stats)
62
- master_line = "#{stats.pid} (#{stats.state_file_path}) Uptime: #{seconds_to_human(stats.uptime)} "
63
- master_line += "| Phase: #{stats.phase} " if stats.phase
62
+ master_line = "#{stats.pid} (#{stats.state_file_path}) Uptime: #{seconds_to_human(stats.uptime)}"
63
+ master_line += " | Phase: #{stats.phase}" if stats.phase
64
64
 
65
65
  if stats.booting?
66
- master_line += warn("booting")
66
+ master_line += " #{warn("booting")}"
67
67
  else
68
- master_line += "| Load: #{color(75, 50, stats.load, asciiThreadLoad(stats.running_threads, stats.max_threads))}"
68
+ master_line += " | Load: #{color(75, 50, stats.load, asciiThreadLoad(stats.running_threads, stats.max_threads))}"
69
+ master_line += " | Req: #{stats.requests_count}" if stats.requests_count
69
70
  end
70
71
 
71
72
  output = [master_line] + stats.workers.map do |wstats|
@@ -77,7 +78,8 @@ def format_stats(stats)
77
78
  worker_line += " #{error("killed")}"
78
79
  else
79
80
  worker_line += " | Load: #{color(75, 50, wstats.load, asciiThreadLoad(wstats.running_threads, wstats.max_threads))}"
80
- worker_line += " Phase: #{error(wstats.phase)}" if wstats.phase != stats.phase
81
+ worker_line += " | Phase: #{error(wstats.phase)}" if wstats.phase != stats.phase
82
+ worker_line += " | Req: #{wstats.requests_count}" if wstats.requests_count
81
83
  worker_line += " Queue: #{error(wstats.backlog.to_s)}" if wstats.backlog > 0
82
84
  worker_line += " Last checkin: #{error(wstats.last_checkin)}" if wstats.last_checkin >= 10
83
85
  end
data/lib/stats.rb CHANGED
@@ -67,6 +67,10 @@ class Stats
67
67
  (Time.now - Time.parse(@wstats['started_at'])).to_i
68
68
  end
69
69
 
70
+ def requests_count
71
+ @wstats.dig('last_status', 'requests_count') || @wstats['requests_count']
72
+ end
73
+
70
74
  def backlog
71
75
  @wstats.dig('last_status', 'backlog') || 0
72
76
  end
@@ -123,6 +127,12 @@ class Stats
123
127
  workers.reduce(0) { |total, wstats| total + wstats.max_threads }
124
128
  end
125
129
 
130
+ def requests_count
131
+ workers_with_requests_count = workers.select(&:requests_count)
132
+ return if workers_with_requests_count.none?
133
+ workers_with_requests_count.reduce(0) { |total, wstats| total + wstats.requests_count }
134
+ end
135
+
126
136
  def running
127
137
  @stats['running'] || 0
128
138
  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.2.1
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoann Lecuyer
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.1.2
129
+ rubygems_version: 3.0.0
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Command-line tool for puma to display information about running request/process