Class: Ape::Server
- Inherits:
-
Object
- Object
- Ape::Server
- Defined in:
- lib/ape/server.rb
Overview
Manages and initializes the Mongrel handler. See run for more details.
Class Method Summary collapse
-
.run(options) ⇒ Object
Starts the Mongrel handler with options given in
options
and maps the /, /ape and /atompub/go URIs to handlers.
Class Method Details
.run(options) ⇒ Object
Starts the Mongrel handler with options given in options
and maps the /, /ape and /atompub/go URIs to handlers.
Options
* :host - the IP address to bind to
* :port - the port number to listen on
* :directory - the ape home directory
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ape/server.rb', line 18 def self.run() Ape.home = [:home] mongrel = Mongrel::Configurator.new(:host => [:host], :port => [:port]) do log "=> Booting mongrel" begin log "=> The ape starting on http://#{[:host]}:#{[:port]}" listener do redirect '/', '/web/index.html' uri '/web', :handler => Mongrel::DirHandler.new( File.(File.dirname(__FILE__) + '/../../web'), true) uri '/atompub/go', :handler => Handler.new end rescue Errno::EADDRINUSE log "ERROR: Address (#{[:host]}:#{[:port]}) is already in use" exit 1 end trap("INT") { stop } trap("TERM") { stop } log "=> Ctrl-C to shutdown" run end mongrel.join end |