node.js - How to detect if a Node spawned process is still running? -
i can spawn process like:
var spawn = require('child_process').spawn; var topiclistener = spawn('python', ['topic_listener.py','node.js'], {env: { twitter_consumer_secret: process.env.twitter_consumer_secret, twitter_consumer_key: process.env.twitter_consumer_key, twitter_token_secret: process.env.twitter_token_secret, twitter_access_token: process.env.twitter_access_token }}); topiclistener.stdout.on('data', function (data) { console.log(data.tostring()); }); topiclistener.stderr.on('data', function (data) { console.log(data.tostring()); }); topiclistener.on('close', function (code) { console.log("exited " + code); });
so of course can control asycnchronously .on(close, ...)
there other way control if process still alive?
spawn('python', ['topic_listener.py','node.js']..
return child process object. use topiclistener.pid
find unique id associated process if it's alive.
Comments
Post a Comment