Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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);
}
}
}
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.');
});
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');
});
}
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) {
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);
}
}
},
caddis.stop = function(callback) {
forever.stop(caddis.server)
.on('stop', function() {
callback();
})
.on('error', function(err) {
callback(err);
});
};
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);
}
}
});