mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
fix: #3865 ensure pm2 never run simultaneous gracefullExit, prevent dump file corruption
This commit is contained in:
parent
e868f003e3
commit
79679db1b3
@ -331,6 +331,12 @@ Daemon.prototype.sendReady = function(cb) {
|
||||
Daemon.prototype.gracefullExit = function() {
|
||||
var that = this;
|
||||
|
||||
// never execute multiple gracefullExit simultaneously
|
||||
// this can lead to loss of some apps in dump file
|
||||
if (this.isExiting) return
|
||||
|
||||
this.isExiting = true
|
||||
|
||||
God.bus.emit('pm2:kill', {
|
||||
status : 'killed',
|
||||
msg : 'pm2 has been killed by SIGNAL'
|
||||
@ -352,6 +358,7 @@ Daemon.prototype.gracefullExit = function() {
|
||||
fs.unlinkSync(that.pid_path);
|
||||
} catch(e) {}
|
||||
setTimeout(function() {
|
||||
that.isExiting = false
|
||||
console.log('Exited peacefully');
|
||||
process.exit(cst.SUCCESS_EXIT);
|
||||
}, 2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user