Cerise config files are written in Ruby and loaded with either
eval() or load(). This provides a familiar
syntax and the flexibility to create complex configuration decisions by
executing Ruby code at runtime. The following sample config files show
the valid options, and their default values. In addition to the standard
options, any other Ruby code may be included as desired.
Configuration files for Cerise itself are located in cerise/cfg. These files are not reloaded at runtime due to the ramifications of changing things such as listening ports, database connection pools, etc while the server is in operation.
server.cfg contains settings for the core Cerise server process.
server {
@host = nil # hostname or address to listen on
@port = 8000 # http port to listen on
@reload = true # reload changed applications
@ssl = true # use SSL
log_config { # logger configuration
@level = Logger::INFO # log level
@files = 10 # number of log files to keep
@max_size = 2_097_152 # maximum size of log file
}
ssl_config { # SSL configuration
@certificate = "cfg/localhost.crt" # public certificate
@private_key = "cfg/localhost.key" # private key
}
session_manager { # configure a session manager
@location = "session/SessionManager" # server resource location
@class = SessionManager # implementing class
@params = { } # optional config parameters
}
user_manager { # configure a user manager
@location = "auth/UserManager" # server resource location
@class = UserManager # implementing class
@params = { } # optional config parameters
}
}
database.cfg contains entries for the database connection pools that Cerise maintains.
database {
@location = "db/Mysql" # server resource name the pool is bound to
@url = 'DBI:Mysql:test' # URL of the database to connect to
@user = 'will' # the user to connect as
@pass = nil # the password to connect with
@min_connections = 1 # the minimum number of open connections
@max_connections = 5 # the maximum number of open connections
@reap_after = 600 # inactive connection timeout (seconds)
}
mailserver.cfg contains entries for the mail server connections that Cerise maintains.
server {
@location = "mail/Default" # server resource location
@host = 'localhost' # server host name
@port = 26 # server port
@starttls = true # encrypt traffic with TLS
@helo_host = 'localhost' # host to identify as
@user = 'user' # smtp-auth username
@pass = 'pass' # smtp-auth password
@auth_type = :cram_md5 # authentication mechanism
}
user.cfg defines the users available to the base UserManager implementation. This is a simple, but insecure, way of maintaining users and groups for access control.
user {
@username = "user" # the user's username
@password = "pass" # the user's password
@groups = %w[ admin ] # optional, the groups the user belongs to
}
Configuration files for Cerise applications are contained within
cerise/apps/<app>/. There is only one file currently,
app.cfg which is reloaded whenever it is changed.
app.cfg contains the base configuration for a Cerise application. It gives details about the application including the base URL it responds to, maps URLs to request handlers, provides configuration parameters for components, etc.
application {
@name = "Cerise Examples" # the name of the application
@base_path = "/examples" # this application handles any
# requests that contain this path
@session_manager = "session/SessionManager" # the SessionManager to use
# requests with, corresponds to
# a @location in server.cfg
@user_manager = "auth/UserManager" # the UserManager to authenticate
# requests with, corresponds to
# a @location in server.cfg
@handler_map = { # mapping of request paths to
/hello/ => Hello, # request handlers
/db/ => Db,
/\.ahtml/ => Cerise::TemplateHandler,
}
@auth_method = :FORM # the authentication method
@default_page = "index.html" # default when no page specified
@error_page = "error.ahtml" # page to display for errors
@login_page = "login.ahtml" # page to display for logins
@secure_paths = { # paths that require the user
/secure/ => "admin" # to be logged in and be a member
} # of the specified group
@parameters[TemplateHandler] = { # configuration parameters, the
:id_attribute => "id", # key for @parameters[key] is a
:delete_id => false, # Class
}
}