require File.join(File.dirname(__FILE__), 'boot') require File.join(File.dirname(__FILE__), 'config', 'server') require File.join(File.dirname(__FILE__), 'config', 'endpoints') # Set port for Jangle DEFAULT_SERVER_PORT = 4141 port = ARGV[0] # use SERVER_PORT variable from config/server.rb port ||= SERVER_PORT if Object.const_defined?("SERVER_PORT") port ||= DEFAULT_SERVER_PORT PORT = port.to_i puts "Starting Jangle core at http://localhost:#{PORT}/" # HTTP access log ACCESS_LOGGER = Logger.new(File.join(APP_ROOT, 'log', 'access.log'), 'daily') # The basic application webapp = App.new # Router webapp.router = HashEndpointRouter.new(ENDPOINTS) # Show routing LOGGER.debug "Using endpoint configuration:" LOGGER.debug ENDPOINTS # Wrap some Rack helpers around the app. webapp = Rack::CommonLogger.new(webapp, ACCESS_LOGGER) webapp = Rack::Reloader.new(webapp) webapp = Rack::ShowExceptions.new(webapp) webapp = Rack::ShowStatus.new(webapp) webapp = Rack::Lint.new(webapp) # Run the app. under a handler: use Mongrel with WEBrick as fall-back begin server = Rack::Handler::Mongrel rescue LoadError => e server = Rack::Handler::WEBrick end server.run(webapp, :Port => PORT)