 			# console.log "\n#{time}: t: #{logged}\n"
 			if cb? then cb(error, result)
 
+
 # Set up Express
+
 app = express()
 app.enable 'trust proxy'
 app.use express.logger()

).asyncMiddleware()


# routing routines

app.get '/node/', (request, response) ->
	response.send 'Node.js is up and running.'


# Exception handling
app.use (error, request, response, next) ->
	code = if error.message is '404' then 404 else 500
	options = request.uonline.basicOpts
	options.code = code
	options.instance = 'error'
	response.status code
	response.render 'error', options


# main

DEFAULT_PORT = 5000
port = process.env.PORT or process.env.OPENSHIFT_NODEJS_PORT or DEFAULT_PORT
ip = process.env.OPENSHIFT_NODEJS_IP or process.env.IP or undefined
console.log "Starting up on port #{port}, and IP is #{ip}"

startupFinished = ->
	console.log "Listening on port #{port}"
	if port is DEFAULT_PORT then console.log "Try http://localhost:#{port}/"

