有一种方法可以监听诸如process.stderr之类的节点进程的事件,我希望事件是当调用此行以在内部做一些逻辑时,是否有可能?
If you mean to listen to the child process spawned from your nodejs server, its simple, i have given the example below.
Note: its very unclear to guess what you mean
var spawn = require('child_process').spawn;
var child = spawn('myshell.sh', []);
child.stdout.on('data', function(data) {
console.log('stdout- ' + data);
});
child.stderr.on('data', function (data) {
console.log('stderr- ' + data);
});
child.on('exit', function (code) {
console.log('exit - ' + code);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.