Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
checkIfPM2ProcessExists(name, (exists) => {
if (exists) {
// TODO: Replace logger.
// logger.debug(`Deleting process ${name}`);
pm2.delete(name, () => {
pm2.disconnect(() => {
process.exit();
});
});
} else {
// TODO: Replace logger.
// logger.warn(`No process with name ${name} exists`);
pm2.disconnect(() => {
process.exit();
});
}
});
});
pm2.describe(name, function (err, apps) {
if (err) {
pm2.disconnect(); // Disconnects from PM2
throw err;
}
// 如果已存在,则先删除再启动
if (apps.length && apps[0].name === name) {
// 删除
pm2.delete(name, function (err, apps) {
if (err) {
pm2.disconnect(); // Disconnects from PM2
throw err;
}
// 启动
pm2.start(pm2ConfigFilePath, function (err, apps) {
console.log('Start local server success!');
pm2.disconnect(); // Disconnects from PM2
if (err) {
throw err;
}
});
});
} else {
pm2.connect((connect_err) => {
pm2.delete(doc.bundleId, (delete_err) => {
// CD BUNDLES DIR
cd(BUNDLE_DIR);
// REMOVE APPLICATON DIR AND BUNDLE FILE
rm('-rf', [
// DIR
doc.bundleId,
// TAR.GZ
`${doc.bundleId}.tar.gz`
]);
// DISCONNECT
pm2.disconnect();
#!/usr/bin/env node
var globalModulesDir = require('global-modules');
var pm2 = require('pm2');
pm2.delete('0', function(err) {})
pm2.disconnect();
process.exit();
checkIfPM2ProcessExists(name, exists => {
if (exists) {
logger.info(`Deleting process ${name}.`);
pm2.delete(name, deleteError => {
if (deleteError) {
logger.error(deleteError);
pm2.disconnect();
process.exit(1);
}
pm2.disconnect();
process.exit(0);
});
} else {
logger.warn(`No process with name ${name} exists.`);
pm2.disconnect();
process.exit(0);
}
});
});
allMiners.forEach(function(miner, idx) {
var
id = miner.slave_index;
pm2.delete(id, function() {
console.log("pm2.delete", id, [].slice.call(arguments));
if (--numMiners === 0) {
allMiners = [];
finished();
}
});
});
} else {
pm2.describe('gxb-box-pm2', function (err, processDescription) {
if (err) {
reject(err);
} else {
if (processDescription.length === 0) {
resolve();
} else {
pm2.delete('gxb-box-pm2', function (err) {
if (err) {
reject(err);
} else {
resolve();
}
});
}
}
});
});
list.forEach((app) =>{
pm2.delete(app.pm2_env.pm_id, (err, res)=> {
delete_count++;
if(delete_count === list.length){
startPm2();
}
});
});
}
new Promise((resolve, reject) => {
del(process, err => {
if (err) {
reject(err);
return;
}
resolve();
return;
});
});
pm2.connect(true,(err)=>{
if(err) return reject(err);
pm2.delete(id, (err, details)=>{
pm2.disconnect();
if(err){
return reject(err);
}
return resolve(details);
});
});
});