Class: PDTP::Server::StatusHandler
- Inherits:
-
Mongrel::HttpHandler
- Object
- Mongrel::HttpHandler
- PDTP::Server::StatusHandler
- Includes:
- StatusHelper
- Defined in:
- lib/pdtp/server/status_handler.rb
Overview
A Mongrel::HttpHandler for generating the status page
Instance Method Summary collapse
-
#initialize(vhost, dispatcher) ⇒ StatusHandler
constructor
A new instance of StatusHandler.
-
#process(request, response) ⇒ Object
Process an incoming request to generate the status page.
Methods included from StatusHelper
#chunks_active, #chunks_completed, #client_count, #cycle, #downstream_bandwidth, #each_file, #each_peer, #each_transfer, #file_path, #peer_address, #peer_name, #percent_complete, #reset_cycle, #transfer_info, #upstream_bandwidth, #vhost
Constructor Details
#initialize(vhost, dispatcher) ⇒ StatusHandler
Returns a new instance of StatusHandler.
36 37 38 39 |
# File 'lib/pdtp/server/status_handler.rb', line 36 def initialize(vhost, dispatcher) @vhost, @dispatcher = vhost, dispatcher @status_erb = File.(File.dirname(__FILE__) + '/../../../status/index.erb') end |
Instance Method Details
#process(request, response) ⇒ Object
Process an incoming request to generate the status page
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pdtp/server/status_handler.rb', line 42 def process(request, response) response.start(200) do |head, out| out.write begin # Read the status page ERb template erb_data = File.read @status_erb # Render the status ERb template html = ERB.new(erb_data).result(binding) # Call reset_cycle from the StatusHelper to reset cycle() calls reset_cycle # Return output html html rescue Exception => e "Exception: #{e}\n#{e.backtrace.join("\n")}" end end end |