### Home Classes Methods

### In Files

- lib/phusion_passenger/message_client.rb

### Parent

Object

### Methods

- ::new
- #check_security_response
- #close
- #connected?
- #helper_agent_backtraces
- #helper_agent_requests
- #logging_agent_status
- #pool_detach_process
- #pool_detach_process_by_key
- #pool_status
- #pool_xml
- #read
- #read_scalar
- #recv_io
- #write
- #write_scalar

### Included Modules

- PhusionPassenger::Utils

### Class/Module Index

Quicksearch

- PhusionPassenger
- PhusionPassenger::AbstractInstaller
- PhusionPassenger::AbstractInstaller::Abort
- PhusionPassenger::AbstractInstaller::CommandError
- PhusionPassenger::AdminTools
- PhusionPassenger::AdminTools::MemoryStats
- PhusionPassenger::AdminTools::MemoryStats::Process
- PhusionPassenger::AdminTools::ServerInstance
- PhusionPassenger::AdminTools::ServerInstance::CorruptedDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::GenerationsAbsentError
- PhusionPassenger::AdminTools::ServerInstance::Group
- PhusionPassenger::AdminTools::ServerInstance::Process
- PhusionPassenger::AdminTools::ServerInstance::RoleDeniedError
- PhusionPassenger::AdminTools::ServerInstance::StaleDirectoryError
- PhusionPassenger::AdminTools::ServerInstance::Stats
- PhusionPassenger::AdminTools::ServerInstance::UnsupportedGenerationStructureVersionError
- PhusionPassenger::AnalyticsLogger
- PhusionPassenger::AnalyticsLogger::Connection
- PhusionPassenger::AnalyticsLogger::Lock
- PhusionPassenger::AnalyticsLogger::Log
- PhusionPassenger::ClassicRails
- PhusionPassenger::ClassicRails::CGIFixed
- PhusionPassenger::ClassicRails::ThreadHandlerExtension
- PhusionPassenger::ConsoleTextTemplate
- PhusionPassenger::DebugLogging
- PhusionPassenger::LoaderSharedHelpers
- PhusionPassenger::MessageChannel
- PhusionPassenger::MessageChannel::InvalidHashError
- PhusionPassenger::MessageClient
- PhusionPassenger::NativeSupportLoader
- PhusionPassenger::Packaging
- PhusionPassenger::PlatformInfo
- PhusionPassenger::PlatformInfo::ApacheDetector
- PhusionPassenger::PlatformInfo::ApacheDetector::Result
- PhusionPassenger::PlatformInfo::Depcheck
- PhusionPassenger::PlatformInfo::Depcheck::ConsoleRunner
- PhusionPassenger::PlatformInfo::Depcheck::Dependency
- PhusionPassenger::PlatformInfo::RuntimeError
- PhusionPassenger::Plugin
- PhusionPassenger::PreloaderSharedHelpers
- PhusionPassenger::Rack
- PhusionPassenger::Rack::OutOfBandGc
- PhusionPassenger::Rack::ThreadHandlerExtension
- PhusionPassenger::Rails3Extensions
- PhusionPassenger::Rails3Extensions::AnalyticsLogging
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ACExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ASBenchmarkableExtension
- PhusionPassenger::Rails3Extensions::AnalyticsLogging::ExceptionLogger
- PhusionPassenger::RequestHandler
- PhusionPassenger::RequestHandler::ThreadHandler
- PhusionPassenger::RequestHandler::ThreadHandler::Interrupted
- PhusionPassenger::SharedConstants
- PhusionPassenger::Standalone
- PhusionPassenger::Standalone::AppFinder
- PhusionPassenger::Standalone::Command
- PhusionPassenger::Standalone::ConfigFile
- PhusionPassenger::Standalone::ConfigFile::DisallowedContextError
- PhusionPassenger::Standalone::HelpCommand
- PhusionPassenger::Standalone::Main
- PhusionPassenger::Standalone::PackageRuntimeCommand
- PhusionPassenger::Standalone::RuntimeInstaller
- PhusionPassenger::Standalone::RuntimeLocator
- PhusionPassenger::Standalone::StartCommand
- PhusionPassenger::Standalone::StatusCommand
- PhusionPassenger::Standalone::StopCommand
- PhusionPassenger::Standalone::Utils
- PhusionPassenger::Standalone::VersionCommand
- PhusionPassenger::Utils
- PhusionPassenger::Utils::AnsiColors
- PhusionPassenger::Utils::FileSystemWatcher
- PhusionPassenger::Utils::FileSystemWatcher::DirInfo
- PhusionPassenger::Utils::FileSystemWatcher::FileInfo
- PhusionPassenger::Utils::GeneratorTest
- PhusionPassenger::Utils::HostsFileParser
- PhusionPassenger::Utils::JSON
- PhusionPassenger::Utils::JSON::Generator
- PhusionPassenger::Utils::ParserTest
- PhusionPassenger::Utils::TeeInput
- PhusionPassenger::Utils::TmpIO
- PhusionPassenger::Utils::UnseekableSocket
- CommonLibraryBuilder
- Exception
- GC
- IO
- Object
- Signal

No matching classes.

# PhusionPassenger::MessageClient

A convenience class for communicating with MessageServer servers, for example the ApplicationPool server.

### Public Class Methods

new(username, password, address = "unix:#{Utils.passenger_tmpdir}/socket") click to toggle source

Connect to the given server. By default it connects to the current generation's helper server.

    # File lib/phusion_passenger/message_client.rb, line 38
    def initialize(username, password, address = "unix:#{Utils.passenger_tmpdir}/socket")
            @socket = connect_to_server(address)
            begin
                    @channel = MessageChannel.new(@socket)

                    result = @channel.read
                    if result.nil?
                            raise EOFError
                    elsif result.size != 2 || result[0] != "version"
                            raise IOError, "The message server didn't sent a valid version identifier"
                    elsif result[1] != "1"
                            raise IOError, "Unsupported message server protocol version #{result[1]}"
                    end

                    @channel.write_scalar(username)
                    @channel.write_scalar(password)

                    result = @channel.read
                    if result.nil?
                            raise EOFError
                    elsif result[0] != "ok"
                            raise SecurityError, result[0]
                    end
            rescue Exception
                    @socket.close
                    raise
            end
    end

### Public Instance Methods

check_security_response() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 174
    def check_security_response
            begin
                    result = @channel.read
            rescue
                    auto_disconnect
                    raise
            end
            if result.nil?
                    raise EOFError
            elsif result[0] != "Passed security"
                    raise SecurityError, result[0]
            end
    end

close() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 67
    def close
            @socket.close if @socket
            @channel = @socket = nil
    end

connected?() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 72
    def connected?
            return !!@channel
    end

helper_agent_backtraces() click to toggle source

HelperAgent BacktracesServer methods ###

    # File lib/phusion_passenger/message_client.rb, line 123
    def helper_agent_backtraces
            write("backtraces")
            check_security_response
            return read_scalar
    end

helper_agent_requests() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 115
    def helper_agent_requests
            write("requests")
            check_security_response
            return read_scalar
    end

logging_agent_status() click to toggle source

LoggingAgent AdminServer methods ###

    # File lib/phusion_passenger/message_client.rb, line 131
    def logging_agent_status
            write("status")
            check_security_response
            return read_scalar
    end

pool_detach_process(pid) click to toggle source

HelperAgent methods ###

    # File lib/phusion_passenger/message_client.rb, line 78
    def pool_detach_process(pid)
            write("detach_process", pid)
            check_security_response
            result = read
            if result.nil?
                    raise EOFError
            else
                    return result.first == "true"
            end
    end

pool_detach_process_by_key(detach_key) click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 89
    def pool_detach_process_by_key(detach_key)
            write("detach_process_by_key", detach_key)
            check_security_response
            result = read
            if result.nil?
                    raise EOFError
            else
                    return result.first == "true"
            end
    end

pool_status(options = {}) click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 100
    def pool_status(options = {})
            write("inspect", *options.to_a.flatten)
            check_security_response
            return read_scalar
    rescue
            auto_disconnect
            raise
    end

pool_xml() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 109
    def pool_xml
            write("toXml", true)
            check_security_response
            return read_scalar
    end

read() click to toggle source

Low level I/O methods ###

    # File lib/phusion_passenger/message_client.rb, line 139
    def read
            return @channel.read
    rescue
            auto_disconnect
            raise
    end

read_scalar() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 160
    def read_scalar
            return @channel.read_scalar
    rescue
            auto_disconnect
            raise
    end

recv_io(klass = IO, negotiate = true) click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 167
    def recv_io(klass = IO, negotiate = true)
            return @channel.recv_io(klass, negotiate)
    rescue
            auto_disconnect
            raise
    end

write(*args) click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 146
    def write(*args)
            @channel.write(*args)
    rescue
            auto_disconnect
            raise
    end

write_scalar(*args) click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 153
    def write_scalar(*args)
            @channel.write_scalar(*args)
    rescue
            auto_disconnect
            raise
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.