 mw = require('./middleware')
 
 # Module variables
-app = express()
+server = express()
 isShuttingDown = false
 FATAL_EXIT_CODE = 13
 

module.exports.start = (options, callback) ->
  port = 3000
  port = options.port if (options && options.port)
  app.listen port, undefined, (callback) ->
    if (app.settings.env != 'test')
      console.log("server listening on port #{port} in #{app.settings.env} mode")


stop = module.exports.stop = (exitCode = 0) ->

#
module.exports.init = (options, callback) ->
  initMiddleware()
  router.buildRoutes(server, options.routes)
  initLibs(callback)

#
