123456789101112131415161718192021222324252627282930313233 |
- var fs= require('fs');
- var path = require('path');
- class IOActivator {
-
- constructor(iopath) {
- var startJSON = path.join(iopath,"start.json");
- this.procName = JSON.parse(fs.readFileSync(startJSON));
- }
- start(context) {
- this.proc = child.exec(this.procName);
- // Write to
- this.proc.stdout.on('data',(data) => {
- //this.iChunk.push(data);
- this.process(data);
- });
- }
- process(data) {
- // Assume json right away "try"
- var msg = JSON.parse(data);
- if(msg == 'emit') {
- this.context.emit(msg.content).done((e) => {
- log.info("Processed: " + e.count);
- });
- }
- }
- stop(context) {
- this.proc.kill('SIGINT');
- }
- }
|