Class | PhusionPassenger::AdminTools::ControlProcess
In: | lib/phusion_passenger/admin_tools/control_process.rb
Parent: | Object

### Methods

backtraces domains for_pid instances list new status xml

### Classes and Modules

Class PhusionPassenger::AdminTools::ControlProcess::Instance

### Attributes

path | [RW] |
pid | [RW] |

### Public Class methods

for_pid(pid)

[Source]

        # File lib/phusion_passenger/admin_tools/control_process.rb, line 60
    60:         def self.for_pid(pid)
    61:                 return list(false).find { |c| c.pid == pid }
    62:         end

list(clean_stale = true)

[Source]

        # File lib/phusion_passenger/admin_tools/control_process.rb, line 42
    42:         def self.list(clean_stale = true)
    43:                 results = []
    44:                 Dir["#{AdminTools.tmpdir}/passenger.*"].each do |dir|
    45:                         next if dir !~ /passenger.(\d+)\Z/
    46:                         begin
    47:                                 results << ControlProcess.new(dir)
    48:                         rescue ArgumentError
    49:                                 # Stale Passenger temp folder. Clean it up if instructed.
    50:                                 if clean_stale
    51:                                         puts "*** Cleaning stale folder #{dir}"
    52:                                         FileUtils.chmod_R(0700, dir) rescue nil
    53:                                         FileUtils.rm_rf(dir)
    54:                                 end
    55:                         end
    56:                 end
    57:                 return results
    58:         end

new(path)

[Source]

        # File lib/phusion_passenger/admin_tools/control_process.rb, line 64
    64:         def initialize(path)
    65:                 @path = path
    66:                 if File.exist?("#{path}/control_process.pid")
    67:                         data = File.read("#{path}/control_process.pid").strip
    68:                         if data.empty?
    69:                                 raise ArgumentError, "'#{path}' is not a valid control process directory."
    70:                         else
    71:                                 @pid = data.to_i
    72:                         end
    73:                 else
    74:                         path =~ /passenger.(\d+)\Z/
    75:                         @pid = $1.to_i
    76:                 end
    77:                 if !AdminTools.process_is_alive?(@pid)
    78:                         raise ArgumentError, "There is no control process with PID #{@pid}."
    79:                 end
    80:         end

### Public Instance methods

backtraces()

[Source]

        # File lib/phusion_passenger/admin_tools/control_process.rb, line 89
    89:         def backtraces
    90:                 connect do |channel|
    91:                         channel.write("backtraces")
    92:                         return channel.read_scalar
    93:                 end
    94:         end

domains()

[Source]

         # File lib/phusion_passenger/admin_tools/control_process.rb, line 103
    103:         def domains
    104:                 doc = REXML::Document.new(xml)
    105:
    106:                 domains = []
    107:                 doc.elements.each("info/domains/domain") do |domain|
    108:                         instances = []
    109:                         d = {
    110:                                 :name => domain.elements["name"].text,
    111:                                 :instances => instances
    112:                         }
    113:                         domain.elements.each("instances/instance") do |instance|
    114:                                 i = Instance.new
    115:                                 instance.elements.each do |element|
    116:                                         if i.respond_to?("#{element.name}=")
    117:                                                 if Instance::INT_PROPERTIES.include?(element.name.to_sym)
    118:                                                         value = element.text.to_i
    119:                                                 else
    120:                                                         value = element.text
    121:                                                 end
    122:                                                 i.send("#{element.name}=", value)
    123:                                         end
    124:                                 end
    125:                                 instances << i
    126:                         end
    127:                         domains << d
    128:                 end
    129:                 return domains
    130:         end

instances()

[Source]

         # File lib/phusion_passenger/admin_tools/control_process.rb, line 132
    132:         def instances
    133:                 return domains.map do |domain|
    134:                         domain[:instances]
    135:                 end.flatten
    136:         end

status()

[Source]

        # File lib/phusion_passenger/admin_tools/control_process.rb, line 82
    82:         def status
    83:                 connect do |channel|
    84:                         channel.write("status")
    85:                         return channel.read_scalar
    86:                 end
    87:         end

xml()

[Source]

         # File lib/phusion_passenger/admin_tools/control_process.rb, line 96
     96:         def xml
     97:                 connect do |channel|
     98:                         channel.write("status_xml")
     99:                         return channel.read_scalar
    100:                 end
    101:         end

[Validate]