Skip to content

Commit c52278e

Browse files
authored
Merge pull request #52 from Kmiet/feature/async-plugin-init
Support for asynchronous plugin initialization
2 parents bba6625 + 884f171 commit c52278e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

common/wfRun.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,22 @@ function hflowRun(opts, runCb) {
179179
//console.log(JSON.stringify(recoveryData, null, 2));
180180
//process.exit(1);
181181

182-
var engine = new Engine(config, wflib, wfId, function(err) {
182+
var engine = new Engine(config, wflib, wfId, async function(err) {
183183
// This represent custom plugin listening on event from available eventServer
184184
// engine.eventServer.on('trace.*', function(exec, args) {
185185
// console.log('Event captured: ' + exec + ' ' + args + ' job done');
186186
// });
187187

188-
plugins.forEach(function(plugin) {
189-
let config = {};
190-
if (plugin.pgType == "scheduler") {
191-
config.wfJson = wfJson;
192-
config.wfId = wfId;
188+
await Promise.all(
189+
plugins.map(function(plugin) {
190+
let config = {};
191+
if (plugin.pgType == "scheduler") {
192+
config.wfJson = wfJson;
193+
config.wfId = wfId;
194+
}
195+
return plugin.init(rcl, wflib, engine, config);
193196
}
194-
plugin.init(rcl, wflib, engine, config);
195-
});
197+
));
196198

197199
engine.syncCb = function () {
198200
process.exit();

0 commit comments

Comments
 (0)