 
   return $eventToPromise webServer, 'close'
 
+#---------------------------------------------------------------------
+
 exports.help = do (pkg = require '../package') ->
   name = $chalk.bold pkg.name
 

    if entry of opts
      console.warn "[Warn] `#{entry}` configuration is deprecated."

  # Creates the web server according to the configuration.
  webServer = new $WebServer()
  $wait $Promise.map opts.http.listen, (options) ->
    # Reads certificate and key if necessary.
    if options.certificate? and options.key?
      options.certificate = $wait $readFile options.certificate
      options.key = $wait $readFile options.key

    # Starts listening
    return webServer.listen(options).then $httpListenSuccess, $httpListenFailure

  # Now the web server is listening, drop privileges.
  try

  # Creates the main object which will connects to Xen servers and
  # manages all the models.
  xo = new $XO()
  xo.start {
    redis: {
      uri: opts.redis?.uri
    }
  }

  # Connect is used for managing non WebSocket connections.
  connect = $connect()
  webServer.on('request', connect)

  # Must be set up before the API.
  setUpConsoleProxy(webServer, xo)

  # Must be set up before the API.
  connect.use $bind xo.handleProxyRequest, xo

  # Must be set up before the static files.
  setUpApi(webServer, xo)

  setUpStaticFiles(connect, opts.http.mounts)

  # Creates a default user if there is none.
  unless $wait xo.users.exists()
