From be26f182ccdff4f96c52d419deebee4aff055e18 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sun, 2 Jul 2017 06:29:58 +0200 Subject: worker in own process --- lib/bridge/monitor.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/bridge/monitor.js (limited to 'lib/bridge/monitor.js') diff --git a/lib/bridge/monitor.js b/lib/bridge/monitor.js new file mode 100644 index 0000000..d8d29ef --- /dev/null +++ b/lib/bridge/monitor.js @@ -0,0 +1,19 @@ +class Monitor { + constructor(args) { + const cmd = spawn(process.env.PYTHON_BINARY, args); + + let stdout = '', stderr = '' + + cmd.stdout.on('data', (data) => { + this.stdout += data + }) + + cmd.stderr.on('data', (data) => { + this.stderr += data + }) + + cmd.on('exit', function (code) { + exit && exit( data.toString() ) + }) + } +} -- cgit v1.2.3-70-g09d2