Class: Honcho::PassengerStatus
- Inherits:
-
Object
- Object
- Honcho::PassengerStatus
- Defined in:
- lib/honcho/passenger_status.rb
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize ⇒ PassengerStatus
constructor
A new instance of PassengerStatus.
Constructor Details
#initialize ⇒ PassengerStatus
Returns a new instance of PassengerStatus.
3 4 5 6 7 |
# File 'lib/honcho/passenger_status.rb', line 3 def initialize @raw = `passenger-status` rescue raise 'could not execute passenger-status' end |
Instance Method Details
#data ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/honcho/passenger_status.rb', line 9 def data return [] if @raw =~ /not serving any applications/ apps = @raw.split(/\-+ Application groups \-+/).last apps.split(/\n\n/).map do |raw_app| next unless (root_match = raw_app.match(/App root: (.+)/)) data = { 'root' => root_match[1] } data['name'] = data['root'].split('/').last data['workers'] = raw_app.scan(/\* PID.*\n.*/).map do |worker| worker.scan(/([\w ]+?) *: ([\d%MGKhms]+)/).each_with_object({}) do |(key, val), hash| hash[key.strip] = val.strip end end data end.compact.sort_by { |a| a['name'] } end |