mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
c5aad50eb4
Puma::App::Status is a rack app that can be used to control the current server. It allows a server to be queried remotely programmaticly.
28 lines
587 B
Ruby
28 lines
587 B
Ruby
module Puma
|
|
module App
|
|
class Status
|
|
def initialize(server)
|
|
@server = server
|
|
end
|
|
|
|
def call(env)
|
|
case env['PATH_INFO']
|
|
when "/stop"
|
|
@server.stop
|
|
return [200, {}, ['{ "status": "ok" }']]
|
|
|
|
when "/halt"
|
|
@server.halt
|
|
return [200, {}, ['{ "status": "ok" }']]
|
|
|
|
when "/stats"
|
|
b = @server.backlog
|
|
r = @server.running
|
|
return [200, {}, ["{ \"backlog\": #{b}, \"running\": #{r} }"]]
|
|
end
|
|
|
|
[404, {}, ["Unsupported action"]]
|
|
end
|
|
end
|
|
end
|
|
end
|