lib/js/Server.js
function(params, options) {
      var t = this,
          port = t.get('port'),
          server = t.get('server'),
          templates = t.get('templates'),
          siteDbPath = t.get('siteDbPath'),
          parentPath = siteDbPath.indexOf('.') === 0 ? process.cwd() : '';

      // Distribute the site path to probes that need it
      t.set('siteDbPath', Path.join(parentPath, siteDbPath));

      // Initialize probes
      SyncProbe.Config.defaultProbe = 'FileSyncProbe';
      SyncProbe.FileSyncProbe.setRootPath(siteDbPath);

      // Expose the current instance so probes running
      // in this process can communicate with the server
      UI.Server.currentServer = t;

      // Internal (non-model) attributes
      t.apps = {};  // Hash appName -> app data
      t.site = null;   // Site model associated with the server

      // Create a connect server if no custom server was specified
      if (!server) {
        server = new Connect();
        t.set({server: server});
      }

      // Attach server components
      server.use(t.siteRoute.bind(t));
      server.use(Connect['static'](Path.join(__dirname, '/../..')));

      // Create a static server to the monitor distribution
      var monitorDistDir = require.resolve('monitor').replace(/lib[\\\/]index.js/, 'dist');
      t.monitorDist = Connect['static'](monitorDistDir);

      // Initialize the template library
      var gruntModules = GruntConfig.MODULE_DEF;
      gruntModules.templates.sort().forEach(function(template){
        var path = Path.normalize(__dirname + '/../../' + template);
        var id = Path.basename(path, '.html');
        templates.add({id:id, path:path});
      });

      // Build the page parameters from the config file
      var styles = "", scripts="";
      gruntModules.client_css.forEach(function(cssFile) {
        styles += CSS_TEMPLATE({cssFile: cssFile.replace('lib/','/static/')});
      });
      var clientScripts = gruntModules.client_ext.concat(gruntModules.shared_js.concat(gruntModules.client_js));
      clientScripts.forEach(function(file) {
        scripts += JS_TEMPLATE({scriptFile: file.replace('lib/','/static/')});
      });
      _.extend(PAGE_PARAMS, {
        styles: styles, scripts: scripts, version: PACKAGE_JSON.version
      });
    }
function(params, options) {
      var t = this,
          port = t.get('port'),
          server = t.get('server'),
          templates = t.get('templates'),
          siteDbPath = t.get('siteDbPath'),
          parentPath = siteDbPath.indexOf('.') === 0 ? process.cwd() : '';

      // Distribute the site path to probes that need it
      t.set('siteDbPath', Path.join(parentPath, siteDbPath));

      // Initialize probes
      SyncProbe.Config.defaultProbe = 'FileSyncProbe';
      SyncProbe.FileSyncProbe.setRootPath(siteDbPath);

      // Expose the current instance so probes running
      // in this process can communicate with the server
      UI.Server.currentServer = t;

      // Internal (non-model) attributes
      t.apps = {};  // Hash appName -> app data
      t.site = null;   // Site model associated with the server

      // Create a connect server if no custom server was specified
      if (!server) {
        server = new Connect();
        t.set({server: server});
      }

      // Attach server components
      server.use(t.siteRoute.bind(t));
      server.use(Connect['static'](Path.join(__dirname, '/../..')));

      // Create a static server to the monitor distribution
      var monitorDistDir = require.resolve('monitor').replace(/lib[\\\/]index.js/, 'dist');
      t.monitorDist = Connect['static'](monitorDistDir);

      // Initialize the template library
      var gruntModules = GruntConfig.MODULE_DEF;
      gruntModules.templates.sort().forEach(function(template){
        var path = Path.normalize(__dirname + '/../../' + template);
        var id = Path.basename(path, '.html');
        templates.add({id:id, path:path});
      });

      // Build the page parameters from the config file
      var styles = "", scripts="";
      gruntModules.client_css.forEach(function(cssFile) {
        styles += CSS_TEMPLATE({cssFile: cssFile.replace('lib/','/static/')});
      });
      var clientScripts = gruntModules.client_ext.concat(gruntModules.shared_js.concat(gruntModules.client_js));
      clientScripts.forEach(function(file) {
        scripts += JS_TEMPLATE({scriptFile: file.replace('lib/','/static/')});
      });
      _.extend(PAGE_PARAMS, {
        styles: styles, scripts: scripts, version: PACKAGE_JSON.version
      });
    }
function ( params , options ) { var t = this , port = t . get ( 'port' ) , server = t . get ( 'server' ) , templates = t . get ( 'templates' ) , siteDbPath = t . get ( 'siteDbPath' ) , parentPath = siteDbPath . indexOf ( '.' ) === 0 ? process . cwd ( ) : '' ; // Distribute the site path to probes that need it t . set ( 'siteDbPath' , Path . join ( parentPath , siteDbPath ) ) ; // Initialize probes SyncProbe . Config . defaultProbe = 'FileSyncProbe' ; SyncProbe . FileSyncProbe . setRootPath ( siteDbPath ) ; // Expose the current instance so probes running // in this process can communicate with the server UI . Server . currentServer = t ; // Internal (non-model) attributes t . apps = { } ; // Hash appName -> app data t . site = null ; // Site model associated with the server // Create a connect server if no custom server was specified if ( ! server ) { server = new Connect ( ) ; t . set ( { server : server } ) ; } // Attach server components server . use ( t . siteRoute . bind ( t ) ) ; server . use ( Connect [ 'static' ] ( Path . join ( __dirname , '/../..' ) ) ) ; // Create a static server to the monitor distribution var monitorDistDir = require . resolve ( 'monitor' ) . replace ( / lib[\\\/]index.js / , 'dist' ) ; t . monitorDist = Connect [ 'static' ] ( monitorDistDir ) ; // Initialize the template library var gruntModules = GruntConfig . MODULE_DEF ; gruntModules . templates . sort ( ) . forEach ( function ( template ) { var path = Path . normalize ( __dirname + '/../../' + template ) ; var id = Path . basename ( path , '.html' ) ; templates . add ( { id : id , path : path } ) ; } ) ; // Build the page parameters from the config file var styles = "" , scripts = "" ; gruntModules . client_css . forEach ( function ( cssFile ) { styles += CSS_TEMPLATE ( { cssFile : cssFile . replace ( 'lib/' , '/static/' ) } ) ; } ) ; var clientScripts = gruntModules . client_ext . concat ( gruntModules . shared_js . concat ( gruntModules . client_js ) ) ; clientScripts . forEach ( function ( file ) { scripts += JS_TEMPLATE ( { scriptFile : file . replace ( 'lib/' , '/static/' ) } ) ; } ) ; _ . extend ( PAGE_PARAMS , { styles : styles , scripts : scripts , version : PACKAGE_JSON . version } ) ; }
Initialize the server
Initialize the server