code: function(ready, listen) {
    if (typeof ready === 'boolean' && typeof listen === 'undefined') {
      listen = ready;
      ready = null;
    }
    listen = typeof listen === 'undefined' ? true : listen; //default to true
    var app = this;
    if (!app.userModel) //delay creation of the user model till now
      app.userModel = models.User;
  
    //////////add routes and final middleware//////////
    var routehooks = [];
    app.emit('namedroutes-install-hook', routehooks);
    app.get("namedRoutes").applyRoutes(routehooks);
  
    //we want this added after routes are applied:
    app._useStaticPaths();
    app.use(function(req, res) {
      res.statusCode = 404;
      res.render("error.html", {
         message: "Page Not Found",
         statusCode: 404
       });
    });
    app.use(errorhandler); //final error handler
    ///////end middleware/////////
  
    //set up clean shutdown on sigterm
    //see http://blog.argteam.com/coding/hardening-node-js-for-production-part-3-zero-downtime-deployments-with-nginx/
    //and https://github.com/visionmedia/express/issues/1366
    process.on( 'SIGTERM', function() {app.stop(null,true);});
    //XXX what about SIGINT (ctrl-c)? closeCallback needs to call process.exit(1) in that case
    if (ready)
      app.addBeforeStartListener(ready);
    return app._beforeStart(listen);
  }
docs: /*
  @param ready (optional) Equivalent of calling app.addBeforeStartListener(ready)
  @param listen (optional) If boolean specifies whether or not the app starts listening.
  If a function, a callback that is invoke when the app starts listening.
  If omitted, defaults to true