mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
#1810 add --kill-timeout <number> option to configure delay before SIGKILL
This commit is contained in:
parent
ba95a80387
commit
55ec8df4bb
1
bin/pm2
1
bin/pm2
@ -32,6 +32,7 @@ commander.version(pkg.version)
|
||||
.option('-o --output <path>', 'specify out log file')
|
||||
.option('-e --error <path>', 'specify error log file')
|
||||
.option('-p --pid <pid>', 'specify pid file')
|
||||
.option('-k --kill-timeout <delay>', 'delay before sending final SIGKILL signal to process')
|
||||
.option('--max-memory-restart <memory>', 'specify max memory amount used to autorestart (in megaoctets)')
|
||||
.option('--restart-delay <delay>', 'specify a delay between restarts (in milliseconds)')
|
||||
.option('--env <environment_name>', 'specify environment to get specific env variables (for JSON declaration)')
|
||||
|
||||
@ -204,10 +204,11 @@ module.exports = function(God) {
|
||||
* @param {} cb
|
||||
* @return Literal
|
||||
*/
|
||||
God.processIsDead = function(pid, cb, sigkill) {
|
||||
God.processIsDead = function(pid, pm2_env, cb, sigkill) {
|
||||
if (!pid) return cb({type : 'param:missing', msg : 'no pid passed'});
|
||||
|
||||
var timeout = null;
|
||||
var timeout = null;
|
||||
var kill_timeout = (pm2_env && pm2_env.kill_timeout) ? pm2_env.kill_timeout : cst.KILL_TIMEOUT;
|
||||
|
||||
var timer = setInterval(function() {
|
||||
if (God.checkProcess(pid) === false) {
|
||||
@ -229,11 +230,13 @@ module.exports = function(God) {
|
||||
else {
|
||||
console.log('Process with pid %d still alive after %sms, sending it SIGKILL now...', pid, cst.KILL_TIMEOUT);
|
||||
try {
|
||||
crossPlatformGroupKill(parseInt(pid),'SIGKILL');
|
||||
} catch(e) { console.error('Process cannot be killed', e.message || e.stack || e); }
|
||||
return God.processIsDead(pid, cb, true);
|
||||
crossPlatformGroupKill(parseInt(pid), 'SIGKILL');
|
||||
} catch(e) {
|
||||
console.error('Process cannot be killed', e.message || e.stack || e);
|
||||
}
|
||||
return God.processIsDead(pid, pm2_env, cb, true);
|
||||
}
|
||||
}, cst.KILL_TIMEOUT);
|
||||
}, kill_timeout);
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -266,7 +269,7 @@ module.exports = function(God) {
|
||||
return cb(null, 'Cannot be killed');
|
||||
}
|
||||
|
||||
return God.processIsDead(pid, cb);
|
||||
return God.processIsDead(pid, pm2_env, cb);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -33,6 +33,9 @@
|
||||
"instances": {
|
||||
"type": "number"
|
||||
},
|
||||
"kill_timeout": {
|
||||
"type": "number"
|
||||
},
|
||||
"port": {
|
||||
"type": "number"
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user