How to use the forever.list 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 avikj / fbash / src / fbash-start.js View on Github external
#!/usr/bin/env node

// if appstate has not already been saved,
// prompts user for credentials and saves appstate
// runs fbash as a daemon using forever

var forever = require('forever');
var readlineSync = require('readline-sync');
var fs = require('fs');
var login = require('facebook-chat-api');
var path = require('path');
var homedir = require('homedir')();

// if fbash processes are already running, stop them
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);
    }
  }
});

var fbashDir = path.join(homedir, '.fbash');

// ensures that the .fbash/ directory exists in the correct location
if (!fs.existsSync(fbashDir)) {
  fs.mkdirSync(fbashDir);
}
github uptownhr / dpanel / bin / dpanel.js View on Github external
dpanel.init().finally(function() {
    forever.list(false, function(err, processes, a) {
        var running = false;
        if (processes) {
            running = processes.some(function(process) {
                return (process.file == '../api.js');
            });
        }

        if (!running) {
            var child = forever.startDaemon('../api.js', {
                max: 3,
                silent: true,
                options: []
            });
        }
    });
github avikj / fbash / src / fbash-stop.js View on Github external
#!/usr/bin/env node

var forever = require('forever');

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 getDaemonMeta(cb) {
  forever.list(false, function(err, list) {
    if (list) {
      for (var i = 0, meta; meta = list[i]; i++) {
        if (meta.file === SCRIPT_PATH) {
          cb(meta);
          return;
        }
      }  
    }    
    cb(null);
  });
}
github bustardcelly / caddis / lib / caddis.js View on Github external
var findInList = function() {
    clearTimeout(timeout);
    forever.list(false, function(context, list) {
      var process = _.find(list, {file:script});
      if(process) {
        callback();
      }
      else {
        timeout = setTimeout(findInList, 500);
      }
    });
  };
  findInList();
github SocketCluster / loadbalancer / bin / cli.js View on Github external
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) {
                    pidIsStillActive = true;
                    break;
                  }
                }
              }
              if (pidIsStillActive) {
                setTimeout(exitWhenComplete, shutDownInterval);

forever

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

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis