Skip to content

Instantly share code, notes, and snippets.

@soyuka
Created February 25, 2015 09:18
Show Gist options
  • Save soyuka/ca813a8baf1c8efb7974 to your computer and use it in GitHub Desktop.
Save soyuka/ca813a8baf1c8efb7974 to your computer and use it in GitHub Desktop.
pm2 test case #1036
pm2 start server.js
ps -ef|grep 'tail -F ~/.pm2/pm2.log'|grep -v grep|wc -l # gives 1
pm2 stop 0
ps -ef|grep 'tail -F ~/.pm2/pm2.log'|grep -v grep|wc -l # gives 0
var http = require('http');
var spawn = require('child_process').spawn
http.createServer(function(req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8020);
var s = spawn('tail', ['-F', '~/.pm2/pm2.log'], {detached: true, stdio: ['ignore', 'ignore', 'ignore']});
//make sure stdio aren't linked to the main process, so that it's detached indeed
s.on('close', function() {
console.log('Spawn closed')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment