Skip to content

Commit

Permalink
kill tail process on close connection
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhtc1202 committed Mar 30, 2018
1 parent 305320e commit 1948a1b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/controllers/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ module.exports = function(config, utils) {
obj.show = function(req, res, next) {
res.header('Content-Type','text/html;charset=utf-8');
var tail = spawn('tail', ['-f', config.app.logPath]);
res.on('close', function(){
console.log("Response ended");
tail.kill("SIGINT");
}).on('finish', function() {
console.log("Response finished successfully");
});
tail.stdout.pipe(res);
};

Expand Down

0 comments on commit 1948a1b

Please sign in to comment.