Server

class
Superclass
Mongrel2::Config( :server )
Included Modules
Mongrel2::Constants

Mongrel2 Server configuration class

Public Class Methods

anchor
by_uuid( uuid )

Return the dataset for looking up a server by its UUID.

# File lib/mongrel2/config/server.rb, line 34
dataset_module do
        def by_uuid( uuid )
                filter(:uuid => uuid).limit(1)
        end
end

Public Instance Methods

anchor
access_log()

Get the path to the server's access log as a String.

# File lib/mongrel2/config/server.rb, line 68
        
anchor
access_log_path()

Get the path to the server's access log as a Pathname

# File lib/mongrel2/config/server.rb, line 69
def access_log_path
        path = self.access_log or return nil
        return Pathname( path )
end
anchor
bind_addr()

The address to bind to on startup.

# File lib/mongrel2/config/server.rb, line 123
        
anchor
by_uuid( uuid )
# File lib/mongrel2/config/server.rb, line 35
def by_uuid( uuid )
        filter(:uuid => uuid).limit(1)
end
anchor
chroot()

Get the name of the directory Mongrel2 will chroot to if run as root as a String.

# File lib/mongrel2/config/server.rb, line 91
        
anchor
chroot_path()

Return a Pathname for the server's chroot directory.

# File lib/mongrel2/config/server.rb, line 92
def chroot_path
        path = self.chroot or return nil
        return Pathname( path )
end
anchor
control_socket()

Return the Mongrel2::Control object for the server's control socket.

# File lib/mongrel2/config/server.rb, line 170
def control_socket
        return Mongrel2::Control.new( self.control_socket_uri )
end
anchor
control_socket_uri()

Return the URI for its control socket.

# File lib/mongrel2/config/server.rb, line 145
def control_socket_uri
        # Find the control socket relative to the server's chroot
        csock_uri = Mongrel2::Config.settings[:control_port] || DEFAULT_CONTROL_SOCKET
        self.log.debug "Chrooted control socket uri is: %p" % [ csock_uri ]

        scheme, sock_path = csock_uri.split( '://', 2 )
        self.log.debug "  chrooted socket path is: %p" % [ sock_path ]

        csock_path = self.chroot_path + sock_path
        if csock_path.socket?
                self.log.debug "  socket path is relative to the chroot: %p" % [ csock_path ]
        else
                csock_path = Pathname.pwd + sock_path
                raise "Unable to find the socket path %p" % [ csock_uri ] unless csock_path.socket?
                self.log.debug "  socket path is relative to the PWD: %p" % [ csock_path ]
        end

        csock_uri = "%s://%s" % [ scheme, csock_path ]

        self.log.debug "  control socket URI is: %p" % [ csock_uri ]
        return csock_uri
end
anchor
default_host()

Get the name of the default virtualhost for the server. If none of the hosts' names (or matching pattern) matches the request's Host: header, the default_host will be used.

# File lib/mongrel2/config/server.rb, line 115
        
anchor
error_log()

Get the path tot he server's error log as a String.

# File lib/mongrel2/config/server.rb, line 79
        
anchor
error_log_path()

Get the path to the server's error log as a Pathname

# File lib/mongrel2/config/server.rb, line 80
def error_log_path
        path = self.error_log or return nil
        return Pathname( path )
end
anchor
filters()

The filters that will be loaded by this server.

# File lib/mongrel2/config/server.rb, line 47
one_to_many :filters
anchor
hosts()

The hosts that belong to this server.

# File lib/mongrel2/config/server.rb, line 43
one_to_many :hosts
anchor
name()

The huamn-readable name of the server.

# File lib/mongrel2/config/server.rb, line 119
        
anchor
pid_file()

Get the path to the server's PID file as a String.

# File lib/mongrel2/config/server.rb, line 102
        
anchor
pid_file_path()

The path to the server's PID file as a Pathname.

# File lib/mongrel2/config/server.rb, line 103
def pid_file_path
        path = self.pid_file or return nil
        return Pathname( path )
end
anchor
port()

The port to listen on.

# File lib/mongrel2/config/server.rb, line 128
        
anchor
to_s()

Stringification method – return a human-readable description of the server.

# File lib/mongrel2/config/server.rb, line 183
def to_s
        return "%s {%s} %s:%d" % [ self.name, self.uuid, self.bind_addr, self.port ]
end
anchor
use_ssl=( enabled )

If enabled, the server will use SSL.

# File lib/mongrel2/config/server.rb, line 135
def use_ssl=( enabled )
        if !enabled || enabled == 0
                super( 0 )
        else
                super( 1 )
        end
end
anchor
use_ssl?()

Returns true if the server uses SSL.

# File lib/mongrel2/config/server.rb, line 129
def use_ssl?
        return self.use_ssl.nonzero?
end
anchor
uuid()

Get the server identifier, which is typically a UUID, but can in reality be any string of alphanumeric characters and dashes.

# File lib/mongrel2/config/server.rb, line 60
        
anchor
uuid=(()

Set the server identifier.

# File lib/mongrel2/config/server.rb, line 64
        
anchor
validate()

Sequel validation callback: add errors if the record is invalid.

# File lib/mongrel2/config/server.rb, line 176
def validate
        self.validates_presence [ :access_log, :error_log, :pid_file, :default_host, :port ],
                message: 'is missing or nil'
end
anchor
xrequests()

The xrequest handlers that will be loaded by this server.

# File lib/mongrel2/config/server.rb, line 51
one_to_many :xrequests,
        :class => 'Mongrel2::Config::XRequest'