lib/master/starter.js
function(command, host, options, cb) {
  let child = null;

  if(env === Constants.RESERVED.ENV_DEV) {
    child = cp.spawn(command, options);
    let prefix = command === Constants.COMMAND.SSH ? '[' + host + '] ' : '';

    child.stderr.on('data', function (chunk) {
      let msg = chunk.toString();
      process.stderr.write(msg);
      if(!!cb) {
        cb(msg);
      }
    });

    child.stdout.on('data', function (chunk) {
      let msg = prefix + chunk.toString();
      process.stdout.write(msg);
    });
  } else {
    child = cp.spawn(command, options, {detached: true, stdio: 'inherit'});
    child.unref();
  }

  child.on('exit', function (code) {
    if(code !== 0) {
      logger.warn('child process exit with error, error code: %s, executed command: %s', code,  command);
    }
    if (typeof cb === 'function') {
      cb(code === 0 ? null : code);
    }
  });
}
function(command, host, options, cb) {
  let child = null;

  if(env === Constants.RESERVED.ENV_DEV) {
    child = cp.spawn(command, options);
    let prefix = command === Constants.COMMAND.SSH ? '[' + host + '] ' : '';

    child.stderr.on('data', function (chunk) {
      let msg = chunk.toString();
      process.stderr.write(msg);
      if(!!cb) {
        cb(msg);
      }
    });

    child.stdout.on('data', function (chunk) {
      let msg = prefix + chunk.toString();
      process.stdout.write(msg);
    });
  } else {
    child = cp.spawn(command, options, {detached: true, stdio: 'inherit'});
    child.unref();
  }

  child.on('exit', function (code) {
    if(code !== 0) {
      logger.warn('child process exit with error, error code: %s, executed command: %s', code,  command);
    }
    if (typeof cb === 'function') {
      cb(code === 0 ? null : code);
    }
  });
}
function ( command , host , options , cb ) { let child = null ; if ( env === Constants . RESERVED . ENV_DEV ) { child = cp . spawn ( command , options ) ; let prefix = command === Constants . COMMAND . SSH ? '[' + host + '] ' : '' ; child . stderr . on ( 'data' , function ( chunk ) { let msg = chunk . toString ( ) ; process . stderr . write ( msg ) ; if ( ! ! cb ) { cb ( msg ) ; } } ) ; child . stdout . on ( 'data' , function ( chunk ) { let msg = prefix + chunk . toString ( ) ; process . stdout . write ( msg ) ; } ) ; } else { child = cp . spawn ( command , options , { detached : true , stdio : 'inherit' } ) ; child . unref ( ) ; } child . on ( 'exit' , function ( code ) { if ( code !== 0 ) { logger . warn ( 'child process exit with error, error code: %s, executed command: %s' , code , command ) ; } if ( typeof cb === 'function' ) { cb ( code === 0 ? null : code ) ; } } ) ; }
Fork child process to run command.

@param {String} command
@param {Object} options
@param {Callback} callback
Fork child process to run command .