### Home Classes Methods

### In Files

- lib/phusion_passenger/message_client.rb

### Parent

Object

### Methods

- ::new
- #backtraces
- #check_security_response
- #close
- #connected?
- #detach
- #read
- #read_scalar
- #recv_io
- #status
- #write
- #write_scalar
- #xml

### 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::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::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::HostsFileParser
- 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

backtraces() click to toggle source

BacktracesServer methods ###

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

check_security_response() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 149
    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

detach(detach_key) click to toggle source

ApplicationPool::Server methods ###

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

read() click to toggle source

Low level I/O methods ###

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

read_scalar() click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 135
    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 142
    def recv_io(klass = IO, negotiate = true)
            return @channel.recv_io(klass, negotiate)
    rescue
            auto_disconnect
            raise
    end

status(options = {}) click to toggle source

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

write(*args) click to toggle source

    # File lib/phusion_passenger/message_client.rb, line 121
    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 128
    def write_scalar(*args)
            @channel.write_scalar(*args)
    rescue
            auto_disconnect
            raise
    end

xml() click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.