Sha256: c33c4f26ccd5d1b3f343542cc72c05456091f8f2462042771af81b9b5fe09b86

Contents?: true

Size: 852 Bytes

Versions: 4

Compression:

Stored size: 852 Bytes

Contents

module Puma
  module App
    class Status
      def initialize(server, cli)
        @server = server
        @cli = cli
      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 "/restart"
          if @cli and @cli.restart_on_stop!
            @server.stop
            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

4 entries across 4 versions & 1 rubygems

Version Path
puma-0.9.1-java lib/puma/app/status.rb
puma-0.9.1 lib/puma/app/status.rb
puma-0.9.0-java lib/puma/app/status.rb
puma-0.9.0 lib/puma/app/status.rb