How to use the forever.stop function in forever

To help you get started, we’ve selected a few forever examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SocketCluster / loadbalancer / bin / cli.js View on Github external
getBalancerIndices(function (err, balancers) {
    if (err) {
      callback && callback('Failed to stop loadbalancer daemons - ' + err);
    } else {
      for (var i = 0; i < balancers.length; i++) {
        forever.stop(balancers[i]);
      }
      var maxShutDownFailures = 20;
      var shutDownFailures = 0;
      var shutDownInterval = 500;
      
      var exitWhenComplete = function () {
        // Only terminate current daemon when all balancers 
        // have been killed.
        getBalancerIndices(function (err, activeBalancers) {
          if (err) {
            callback && callback('Failed to stop loadbalancer daemon - ' + err);
          } else if (++shutDownFailures > maxShutDownFailures) {
            callback && callback('Failed to stop loadbalancer daemon');
          } else {
            if (activeBalancers.length) {
              setTimeout(exitWhenComplete, shutDownInterval);
github lazojs / lazo / run.js View on Github external
function stop() {
    var forever = require('forever'),
        fsx = require('fs-extra');

    console.log('Stopping Lazo!...');
    if (fsx.existsSync(lazoPath + '/lazo.pid')) {
        try {
            forever.stop('lib/server/app.js', true);
            forever.cleanUp();
            fsx.remove(lazoPath + '/lazo.pid');
            console.log('Lazo! stopped');
        } catch (err) {
            console.log('Error stopping Lazo!');
            process.exit(1);
        }
    }
}
github avikj / fbash / src / fbash-stop.js View on Github external
forever.list(false, function(err, data){
  if(data == null) return;
  for(var i = 0; i < data.length; i++){
    if(data[i].uid === 'fbash'){
      forever.stop(i);
    }
  }
  console.log('fbash stopped.');
});
github jiem / start-stop-daemon / index.js View on Github external
function stop() {  
  forever.stop(SCRIPT_PATH)
    .on('stop', function(scripts) {
      fs.unlinkSync(scripts[0].pidFile);
      console.log('\033[32m' + SCRIPT + ' daemon successfully stopped\033[0m');
    })
    .on('error', function() {
      console.log('\033[31m' + SCRIPT + ' daemon not running or user not authorized to stop process\033[39m');
    });      
}
github SocketCluster / loadbalancer / bin / cli.js View on Github external
forever.list(false, function (err, children) {
    if (err) {
      callback && callback('Failed to stop loadbalancer daemon at index ' + index + ' - ' + err);
    } else {
      var proc;
      if (children) {
        proc = children[index];
      }
      if (proc) {
        var pid = proc.pid;
        
        forever.stop(index);
        
        var maxShutDownFailures = 20;
        var shutDownFailures = 0;
        var shutDownInterval = 500;
        
        var exitWhenComplete = function () {
          forever.list(false, function (err, children) {
            if (err) {
              callback && callback('Failed to stop loadbalancer daemon at index ' + index + ' - ' + err);
            } else if (++shutDownFailures > maxShutDownFailures) {
              callback && callback('Failed to stop loadbalancer daemon');
            } else {
              var pidIsStillActive = false;
              if (children) {
                for (var i = 0; i < children.length; i++) {
                  if (children[i].pid == pid) {
github xiaojue / fd-server / lib / commanders.js View on Github external
exec: function() {
				if (isWin) {
					logger.error('windows system not supported start daemon');
				} else {
					function _start() {
						var child = forever.startDaemon(masterScript, foreverOptions);
						logger.info('log file ' + foreverOptions.logFile);
						logger.info('open http://local.fd.server/ to check the server!');
					}
					forever.stop(foreverOptions.uid).on('stop', _start).on('error', _start);
				}
			}
		},
github bustardcelly / caddis / lib / caddis.js View on Github external
caddis.stop = function(callback) {
  forever.stop(caddis.server)
    .on('stop', function() {
      callback();
    })
    .on('error', function(err) {
      callback(err);
    });
};
github avikj / fbash / src / fbash-start.js View on Github external
forever.list(false, function(err, data) {
  if (err) throw err;
  if (data == null) return;
  for (var i = 0; i < data.length; i++) {
    if (data[i].uid === 'fbash'){
      forever.stop(i);
    }
  }
});

forever

A simple CLI tool for ensuring that a given node script runs continuously (i.e. forever)

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis