Sha256: 33180f564952456bc9f3b9408aa7fe3e12d7dff22005f795d1da1877d09f6b08
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
module Puma module App class Status def initialize(server, cli) @server = server @cli = cli @auth_token = nil end attr_accessor :auth_token def authenticate(env) return true unless @auth_token env['QUERY_STRING'].to_s.split(/&;/).include?("token=#{@auth_token}") end def call(env) unless authenticate(env) return [403, {}, ["Invalid auth token"]] end case env['PATH_INFO'] when "/stop" @server.stop return [200, {}, ['{ "status": "ok" }']] when "/halt" @server.halt return [200, {}, ['{ "status": "ok" }']] when "/restart" if @cli and @cli.restart_on_stop! @server.begin_restart return [200, {}, ['{ "status": "ok" }']] else return [200, {}, ['{ "status": "not configured" }']] end when "/stats" b = @server.backlog r = @server.running return [200, {}, ["{ \"backlog\": #{b}, \"running\": #{r} }"]] end [404, {}, ["Unsupported action"]] end end end end
Version data entries
6 entries across 6 versions & 1 rubygems