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.
- #running ⇒ Object
- #to_s ⇒ Object
- #workers ⇒ Object
Constructor Details
#initialize(stats) ⇒ Status
Returns a new instance of Status.
231 232 233 |
# File 'lib/puma/plugin/systemd.rb', line 231 def initialize(stats) @stats = stats end |
Instance Method Details
#backlog ⇒ Object
255 256 257 258 259 260 261 |
# File 'lib/puma/plugin/systemd.rb', line 255 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
243 244 245 |
# File 'lib/puma/plugin/systemd.rb', line 243 def booted_workers @stats.fetch("booted_workers", 1) end |
#clustered? ⇒ Boolean
235 236 237 |
# File 'lib/puma/plugin/systemd.rb', line 235 def clustered? @stats.has_key? "workers" end |
#running ⇒ Object
247 248 249 250 251 252 253 |
# File 'lib/puma/plugin/systemd.rb', line 247 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
263 264 265 266 267 268 269 |
# File 'lib/puma/plugin/systemd.rb', line 263 def to_s if clustered? "puma #{Puma::Const::VERSION} cluster: #{booted_workers}/#{workers} workers: #{running} threads, #{backlog} backlog" else "puma #{Puma::Const::VERSION}: #{running} threads, #{backlog} backlog" end end |
#workers ⇒ Object
239 240 241 |
# File 'lib/puma/plugin/systemd.rb', line 239 def workers @stats.fetch("workers", 1) end |