lib/daemon.js
function daemonize(file, conf, args) {
  /* istanbul ignore next: never parse argv in test env */
  args = args || process.argv.slice(2);
  args.unshift(file);
  var logfile = conf.get(ConfigKey.LOGFILE) || '/dev/null'
  //var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'
    , out = fs.openSync(logfile, 'a')
    , err = fs.openSync(logfile, 'a')
    , opts = {
      detached: true,
      stdio: ['ignore', out, err],
      cwd: process.cwd(),
      env: process.env
    };

  //console.dir(logfile);
  //console.dir(args);

  var ps = spawn(cmd, args, opts);
  /* istanbul ignore next: always in test env */
  if(process.env.NODE_ENV !== Constants.TEST) {
    process.exit(0);
  }
  return ps.pid;
}
function daemonize(file, conf, args) {
  /* istanbul ignore next: never parse argv in test env */
  args = args || process.argv.slice(2);
  args.unshift(file);
  var logfile = conf.get(ConfigKey.LOGFILE) || '/dev/null'
  //var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log'
    , out = fs.openSync(logfile, 'a')
    , err = fs.openSync(logfile, 'a')
    , opts = {
      detached: true,
      stdio: ['ignore', out, err],
      cwd: process.cwd(),
      env: process.env
    };

  //console.dir(logfile);
  //console.dir(args);

  var ps = spawn(cmd, args, opts);
  /* istanbul ignore next: always in test env */
  if(process.env.NODE_ENV !== Constants.TEST) {
    process.exit(0);
  }
  return ps.pid;
}
function daemonize ( file , conf , args ) { /* istanbul ignore next: never parse argv in test env */ args = args || process . argv . slice ( 2 ) ; args . unshift ( file ) ; var logfile = conf . get ( ConfigKey . LOGFILE ) || '/dev/null' //var logfile = conf.get(ConfigKey.LOGFILE) || 'daemon.log' , out = fs . openSync ( logfile , 'a' ) , err = fs . openSync ( logfile , 'a' ) , opts = { detached : true , stdio : [ 'ignore' , out , err ] , cwd : process . cwd ( ) , env : process . env } ; //console.dir(logfile); //console.dir(args); var ps = spawn ( cmd , args , opts ) ; /* istanbul ignore next: always in test env */ if ( process . env . NODE_ENV !== Constants . TEST ) { process . exit ( 0 ) ; } return ps . pid ; }
Create the daemon process.
Create the daemon process .