Skip to content

Commit 79679db

Browse files
committed
fix: #3865 ensure pm2 never run simultaneous gracefullExit, prevent dump file corruption
1 parent e868f00 commit 79679db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Daemon.js

+7
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@ Daemon.prototype.sendReady = function(cb) {
331331
Daemon.prototype.gracefullExit = function() {
332332
var that = this;
333333

334+
// never execute multiple gracefullExit simultaneously
335+
// this can lead to loss of some apps in dump file
336+
if (this.isExiting) return
337+
338+
this.isExiting = true
339+
334340
God.bus.emit('pm2:kill', {
335341
status : 'killed',
336342
msg : 'pm2 has been killed by SIGNAL'
@@ -352,6 +358,7 @@ Daemon.prototype.gracefullExit = function() {
352358
fs.unlinkSync(that.pid_path);
353359
} catch(e) {}
354360
setTimeout(function() {
361+
that.isExiting = false
355362
console.log('Exited peacefully');
356363
process.exit(cst.SUCCESS_EXIT);
357364
}, 2);

0 commit comments

Comments
 (0)