tasks/forever-task.js
function restartOnProcess( index ) {
  log( 'Attempting to restart ' + index + '...' );

  // generate delegate function to pass with proper contexts.
  var startRequest = (function(context, index) {
    return function(cb) {
        startForeverWithIndex.call(context, index, cb);
    };
  }(this, index));

  done = this.async();
  findProcessWithIndex( index, function(process) {
    if(typeof process !== 'undefined') {
      log(forever.format(true,[process]));
      forever.restart(index, false);
      done();
    }
    else {
      log(index + ' not found in list of processes in forever. Starting new instance...');
      startRequest(done);
    }
  });
}
function restartOnProcess( index ) {
  log( 'Attempting to restart ' + index + '...' );

  // generate delegate function to pass with proper contexts.
  var startRequest = (function(context, index) {
    return function(cb) {
        startForeverWithIndex.call(context, index, cb);
    };
  }(this, index));

  done = this.async();
  findProcessWithIndex( index, function(process) {
    if(typeof process !== 'undefined') {
      log(forever.format(true,[process]));
      forever.restart(index, false);
      done();
    }
    else {
      log(index + ' not found in list of processes in forever. Starting new instance...');
      startRequest(done);
    }
  });
}
function restartOnProcess ( index ) { log ( 'Attempting to restart ' + index + '...' ) ; // generate delegate function to pass with proper contexts. var startRequest = ( function ( context , index ) { return function ( cb ) { startForeverWithIndex . call ( context , index , cb ) ; } ; } ( this , index ) ) ; done = this . async ( ) ; findProcessWithIndex ( index , function ( process ) { if ( typeof process !== 'undefined' ) { log ( forever . format ( true , [ process ] ) ) ; forever . restart ( index , false ) ; done ( ) ; } else { log ( index + ' not found in list of processes in forever. Starting new instance...' ) ; startRequest ( done ) ; } } ) ; }
Attempts to stop and restart a process previously started associated with index. If no process found as previously started, just starts a new one.
@param  {String} index Filename associated with previously started process.
Attempts to stop and restart a process previously started associated with index . If no process found as previously started just starts a new one .