mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
refactor kill interact
This commit is contained in:
parent
b2455cb440
commit
e560a4c30f
@ -1386,17 +1386,16 @@ CLI.ilogs = function() {
|
||||
CLI.killDaemon = function(cb) {
|
||||
printOut(cst.PREFIX_MSG + 'Stopping PM2...');
|
||||
|
||||
this.delete('all', function(err, list) {
|
||||
CLI._operate('deleteProcessId', 'all', function(err, list) {
|
||||
printOut(cst.PREFIX_MSG + 'All processes has been stopped and deleted');
|
||||
|
||||
InteractorDaemonizer.killDaemon(function() {
|
||||
InteractorDaemonizer.killDaemon(function(err, data) {
|
||||
Satan.killDaemon(function(err, res) {
|
||||
if (err) printError(err);
|
||||
printOut(cst.PREFIX_MSG + 'PM2 stopped');
|
||||
return cb ? cb(null) : exitCli(cst.SUCCESS_EXIT);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -49,24 +49,32 @@ InteractorDaemonizer.ping = function(cb) {
|
||||
|
||||
InteractorDaemonizer.killDaemon = function(cb) {
|
||||
|
||||
debug('Killing interactor #1 ping');
|
||||
InteractorDaemonizer.ping(function(online) {
|
||||
debug('Interactor online', online);
|
||||
if (!online) {
|
||||
if (!cb) Common.printError('Interactor not launched');
|
||||
return cb ? cb({msg:'Interactor not launched'}) : Common.exitCli(cst.SUCCESS_EXIT);
|
||||
}
|
||||
// debug('Killing interactor #1 ping');
|
||||
// InteractorDaemonizer.ping(function(online) {
|
||||
// debug('Interactor online', online);
|
||||
|
||||
InteractorDaemonizer.launchRPC(function() {
|
||||
InteractorDaemonizer.rpc.kill(function(err) {
|
||||
if (err) Common.printError(err);
|
||||
setTimeout(function() {
|
||||
InteractorDaemonizer.disconnectRPC(cb);
|
||||
}, 100);
|
||||
});
|
||||
// if (!online) {
|
||||
// if (!cb) Common.printError('Interactor not launched');
|
||||
// return cb ? cb({msg:'Interactor not launched'}) : Common.exitCli(cst.SUCCESS_EXIT);
|
||||
// }
|
||||
|
||||
InteractorDaemonizer.launchRPC(function(err, data) {
|
||||
if (err) {
|
||||
setTimeout(function() {
|
||||
InteractorDaemonizer.disconnectRPC(cb);
|
||||
}, 100);
|
||||
return false;
|
||||
}
|
||||
InteractorDaemonizer.rpc.kill(function(err) {
|
||||
if (err) Common.printError(err);
|
||||
setTimeout(function() {
|
||||
InteractorDaemonizer.disconnectRPC(cb);
|
||||
}, 100);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
//return false;
|
||||
//});
|
||||
};
|
||||
|
||||
/**
|
||||
@ -112,7 +120,11 @@ InteractorDaemonizer.launchRPC = function(cb) {
|
||||
});
|
||||
};
|
||||
|
||||
this.client.sock.on('error', function(e) {
|
||||
this.client.sock.once('reconnect attempt', function(e) {
|
||||
return cb({success:false, msg:'reconnect attempt'});
|
||||
});
|
||||
|
||||
this.client.sock.once('error', function(e) {
|
||||
console.error('Error in error catch all on Interactor');
|
||||
console.error(e.stack || e);
|
||||
});
|
||||
@ -120,15 +132,11 @@ InteractorDaemonizer.launchRPC = function(cb) {
|
||||
this.client.sock.once('connect', function() {
|
||||
generateMethods(function() {
|
||||
debug('Methods generated');
|
||||
cb();
|
||||
cb(null, {success:true});
|
||||
});
|
||||
});
|
||||
|
||||
this.client_sock = req.connect(cst.INTERACTOR_RPC_PORT);
|
||||
|
||||
this.client_sock.on('error', function() {
|
||||
console.log('Got errorrororo');
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
58
test/fixtures/ecosystem.json5
vendored
Normal file
58
test/fixtures/ecosystem.json5
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
{
|
||||
/**
|
||||
* This is a sample configuration file for PM2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Here we declare the apps that must be managed by PM2
|
||||
* All options are listed here:
|
||||
* https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#json-app-declaration
|
||||
*
|
||||
*/
|
||||
apps : [
|
||||
|
||||
// First application
|
||||
{
|
||||
name : "API",
|
||||
script : "app.js",
|
||||
env: {
|
||||
COMMON_VARIABLE: "true"
|
||||
},
|
||||
env_production : {
|
||||
NODE_ENV: "production"
|
||||
}
|
||||
},
|
||||
|
||||
// Second application
|
||||
{
|
||||
name : "WEB",
|
||||
script : "web.js"
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
|
||||
/**
|
||||
* PM2 help you to deploy apps over your servers
|
||||
* For more help go to :
|
||||
* https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#deployment-pm2--090
|
||||
*/
|
||||
deploy : {
|
||||
production : {
|
||||
user : "node",
|
||||
host : "212.83.163.1",
|
||||
ref : "origin/master",
|
||||
repo : "git@github.com:repo.git",
|
||||
path : "/var/www/production",
|
||||
"post-deploy" : "pm2 startOrRestart ecosystem.json --env production"
|
||||
},
|
||||
dev : {
|
||||
user : "node",
|
||||
host : "212.83.163.1",
|
||||
ref : "origin/master",
|
||||
repo : "git@github.com:repo.git",
|
||||
path : "/var/www/development",
|
||||
"post-deploy" : "pm2 startOrRestart ecosystem.json --env dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user