lib/service.js
function parseServiceJson(serviceNameFilter, serviceJson) {
  var services = [],
    config = require('./config')();

  Object.keys(serviceJson).forEach(function(serviceName) {
    if (serviceName === 'env' || serviceName === 'args') return;

    var serviceConfig = serviceJson[serviceName],
      processCount = serviceConfig.processes || 1;

    // if services have a process count > 1,
    // we'll create multiple run-scripts for them.
    _.range(processCount).forEach(function(i) {

      // apply sane defaults as we create
      // the services.
      var service = new Service(_.extend(
        {
          module: serviceName,
          name: i > 0 ? (serviceName + '-' + i) : serviceName
        },
        serviceConfig
      ));

      // override env and args with global args and env.
      service.env = _.extend({},
        dropInterviewQuestions(serviceJson.env),
        dropInterviewQuestions(serviceConfig.env)
      );

      service.args = serviceConfig.args;

      if (_.isArray(serviceConfig.args)) {
        // combine arrays of arguments, if both top-level args.
        // and service-level args are an array.
        if (_.isArray(serviceJson.args)) service.args = [].concat(serviceJson.args, service.args);
      } else {
        // merge objects together if top-level, and service level
        // arguments are maps.
        service.args = _.extend({},
          dropInterviewQuestions(serviceJson.args),
          dropInterviewQuestions(serviceConfig.args)
        );
      }

      // we can optionaly filter to a specific service name.
      if (serviceNameFilter && service.name !== serviceNameFilter && !config.globalPackage) return;

      // replace placeholder variables
      // in the service.json.
      expandVariables(service, i);

      services.push(service);
    });
  });

  return services;
}
function parseServiceJson(serviceNameFilter, serviceJson) {
  var services = [],
    config = require('./config')();

  Object.keys(serviceJson).forEach(function(serviceName) {
    if (serviceName === 'env' || serviceName === 'args') return;

    var serviceConfig = serviceJson[serviceName],
      processCount = serviceConfig.processes || 1;

    // if services have a process count > 1,
    // we'll create multiple run-scripts for them.
    _.range(processCount).forEach(function(i) {

      // apply sane defaults as we create
      // the services.
      var service = new Service(_.extend(
        {
          module: serviceName,
          name: i > 0 ? (serviceName + '-' + i) : serviceName
        },
        serviceConfig
      ));

      // override env and args with global args and env.
      service.env = _.extend({},
        dropInterviewQuestions(serviceJson.env),
        dropInterviewQuestions(serviceConfig.env)
      );

      service.args = serviceConfig.args;

      if (_.isArray(serviceConfig.args)) {
        // combine arrays of arguments, if both top-level args.
        // and service-level args are an array.
        if (_.isArray(serviceJson.args)) service.args = [].concat(serviceJson.args, service.args);
      } else {
        // merge objects together if top-level, and service level
        // arguments are maps.
        service.args = _.extend({},
          dropInterviewQuestions(serviceJson.args),
          dropInterviewQuestions(serviceConfig.args)
        );
      }

      // we can optionaly filter to a specific service name.
      if (serviceNameFilter && service.name !== serviceNameFilter && !config.globalPackage) return;

      // replace placeholder variables
      // in the service.json.
      expandVariables(service, i);

      services.push(service);
    });
  });

  return services;
}
function parseServiceJson ( serviceNameFilter , serviceJson ) { var services = [ ] , config = require ( './config' ) ( ) ; Object . keys ( serviceJson ) . forEach ( function ( serviceName ) { if ( serviceName === 'env' || serviceName === 'args' ) return ; var serviceConfig = serviceJson [ serviceName ] , processCount = serviceConfig . processes || 1 ; // if services have a process count > 1, // we'll create multiple run-scripts for them. _ . range ( processCount ) . forEach ( function ( i ) { // apply sane defaults as we create // the services. var service = new Service ( _ . extend ( { module : serviceName , name : i > 0 ? ( serviceName + '-' + i ) : serviceName } , serviceConfig ) ) ; // override env and args with global args and env. service . env = _ . extend ( { } , dropInterviewQuestions ( serviceJson . env ) , dropInterviewQuestions ( serviceConfig . env ) ) ; service . args = serviceConfig . args ; if ( _ . isArray ( serviceConfig . args ) ) { // combine arrays of arguments, if both top-level args. // and service-level args are an array. if ( _ . isArray ( serviceJson . args ) ) service . args = [ ] . concat ( serviceJson . args , service . args ) ; } else { // merge objects together if top-level, and service level // arguments are maps. service . args = _ . extend ( { } , dropInterviewQuestions ( serviceJson . args ) , dropInterviewQuestions ( serviceConfig . args ) ) ; } // we can optionaly filter to a specific service name. if ( serviceNameFilter && service . name !== serviceNameFilter && ! config . globalPackage ) return ; // replace placeholder variables // in the service.json. expandVariables ( service , i ) ; services . push ( service ) ; } ) ; } ) ; return services ; }
service.json files can be used to describe multiple services, they have a slightly different format than package.json.
service . json files can be used to describe multiple services they have a slightly different format than package . json .