Skip to content

Commit

Permalink
Merge pull request #3876 from Unitech/lost_apps_sigterm
Browse files Browse the repository at this point in the history
fix: #3865
  • Loading branch information
wallet77 committed Aug 22, 2018
2 parents 8e6481b + 79679db commit 4fa247a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Daemon.js
Expand Up @@ -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'
Expand All @@ -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);
Expand Down

0 comments on commit 4fa247a

Please sign in to comment.