This repository has been archived on 2025-10-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
gekko/core/workers/pipeline/parent.js
2021-06-06 20:25:14 +02:00

35 lines
717 B
JavaScript

var fork = require('child_process').fork;
module.exports = (mode, config, callback) => {
var debug = typeof v8debug === 'object';
if (debug) {
process.execArgv = [];
}
var child = fork(__dirname + '/child');
// How we should handle client messages depends
// on the mode of the Pipeline that is being ran.
var handle = require('./messageHandlers/' + mode + 'Handler')(callback);
var message = {
what: 'start',
mode: mode,
config: config
};
child.on('message', function(m) {
if(m === 'ready')
return child.send(message);
if(m === 'done')
return child.send({what: 'exit'});
handle.message(m);
});
child.on('exit', handle.exit);
return child;
}