Class: Puma::Plugin::Systemd::Status
- Inherits:
-
Object
- Object
- Puma::Plugin::Systemd::Status
- Defined in:
- lib/puma/plugin/systemd.rb
Overview
Take puma’s stats and construct a sensible status line for Systemd
Instance Method Summary collapse
- #backlog ⇒ Object
- #booted_workers ⇒ Object
- #clustered? ⇒ Boolean
-
#initialize(stats) ⇒ Status
constructor
A new instance of Status.
- #max_threads ⇒ Object
- #pool_capacity ⇒ Object
- #running ⇒ Object
- #to_s ⇒ Object
- #workers ⇒ Object
Constructor Details
#initialize(stats) ⇒ Status
Returns a new instance of Status.
235 236 237 |
# File 'lib/puma/plugin/systemd.rb', line 235 def initialize(stats) @stats = stats end |
Instance Method Details
#backlog ⇒ Object
259 260 261 262 263 264 265 |
# File 'lib/puma/plugin/systemd.rb', line 259 def backlog if clustered? @stats["worker_status"].map { |s| s["last_status"].fetch("backlog", 0) }.inject(0, &:+) else @stats.fetch("backlog", 0) end end |
#booted_workers ⇒ Object
247 248 249 |
# File 'lib/puma/plugin/systemd.rb', line 247 def booted_workers @stats.fetch("booted_workers", 1) end |
#clustered? ⇒ Boolean
239 240 241 |
# File 'lib/puma/plugin/systemd.rb', line 239 def clustered? @stats.has_key? "workers" end |
#max_threads ⇒ Object
275 276 277 278 279 280 281 |
# File 'lib/puma/plugin/systemd.rb', line 275 def max_threads if clustered? @stats["worker_status"].map { |s| s["last_status"].fetch("max_threads", 0) }.inject(0, &:+) else @stats.fetch("max_threads", 0) end end |
#pool_capacity ⇒ Object
267 268 269 270 271 272 273 |
# File 'lib/puma/plugin/systemd.rb', line 267 def pool_capacity if clustered? @stats["worker_status"].map { |s| s["last_status"].fetch("pool_capacity", 0) }.inject(0, &:+) else @stats.fetch("pool_capacity", 0) end end |
#running ⇒ Object
251 252 253 254 255 256 257 |
# File 'lib/puma/plugin/systemd.rb', line 251 def running if clustered? @stats["worker_status"].map { |s| s["last_status"].fetch("running", 0) }.inject(0, &:+) else @stats.fetch("running", 0) end end |
#to_s ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/puma/plugin/systemd.rb', line 283 def to_s if clustered? "puma #{Puma::Const::VERSION} cluster: #{booted_workers}/#{workers} workers: #{running}/#{max_threads} threads, #{pool_capacity} available, #{backlog} backlog" else "puma #{Puma::Const::VERSION}: #{running}/#{max_threads} threads, #{pool_capacity} available, #{backlog} backlog" end end |
#workers ⇒ Object
243 244 245 |
# File 'lib/puma/plugin/systemd.rb', line 243 def workers @stats.fetch("workers", 1) end |