Class: Rack::ServerStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/server_status.rb,
lib/rack/server_status/version.rb

Defined Under Namespace

Classes: Remover

Constant Summary collapse

VERSION =
"0.0.2"

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ ServerStatus

Returns a new instance of ServerStatus.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rack/server_status.rb', line 7

def initialize(app, options = {})
  @app             = app
  @uptime          = Time.now.to_i
  @skip_ps_command = options[:skip_ps_command] || false
  @path            = options[:path]            || '/server-status'
  @allow           = options[:allow] || []
  scoreboard_path  = options[:scoreboard_path]
  unless scoreboard_path.nil?
    @scoreboard = WorkerScoreboard.new(scoreboard_path)
  end
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rack/server_status.rb', line 19

def call(env)
  set_state!('A', env)

  @clean_proc = Remover.new
  ObjectSpace.define_finalizer(self, @clean_proc)

  if @path && env['PATH_INFO'] == @path
    res = handle_server_status(env)
    set_state!('_')
    return res
  end

  res = @app.call(env)
  set_state!('_')
  return res
end