Skip to content

Commit

Permalink
Merge pull request #333 from fb55/master
Browse files Browse the repository at this point in the history
Remove pid-files on `exit` and `stop`
  • Loading branch information
indexzero committed Nov 29, 2012
2 parents 094ebd4 + e52b063 commit 6ee6f9a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/monitor
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ function start(options) {
monitor.on('restart', function () {
writePid(options.pidFile, monitor.child.pid);
});


//
// When the monitor stops or exits, remove the pid and log files
//
function cleanUp(){
try {
fs.unlinkSync(options.pidFile);
}
catch(e){}
}
monitor.on('stop', cleanUp);
monitor.on('exit', cleanUp);
}

//
Expand Down

0 comments on commit 6ee6f9a

Please sign in to comment.