Closed sgvadodariya closed 6 years ago
Hi @sgvadodariya apologies for the delayed response. You need to initialise the store which should probably be done processus.js itself. Anyway, here's a work around
var processus = require('processus');
var store = require('processus/engine/persistence/store');
store.initStore(function(err){
console.log(err);
});
var wf = {
"name": "Example Workflow",
"description": "An example workflow using the API.",
"tasks":{
"task 1": {
"description": "Demo task to execute echo command.",
"blocking": true,
"handler" : "../taskhandlers/execHandler",
"parameters": {
"cmd": "echo 'Congratulations you called a workflow using the API.'"
}
}
}
};
processus.execute(wf, function(err, workflow){
if(!err) {
console.log(workflow.tasks['task 1'].parameters.stdout);
}
else {
console.log(err);
}
});
which should result in the following:
info: ⧖ Starting task [task 1]
info: Congratulations you called a workflow using the API.
info: ✔ task task 1 completed successfully.
Congratulations you called a workflow using the API.
For more info on the store and parameters, look at how the cli.js code uses processes to do the same.
Updated readme to include store initialization in API example. Closing this accordingly.
var processus = require('processus');
var wf = { "name": "Example Workflow", "description": "An example workflow using the API.", "tasks":{ "task 1": { "description": "Demo task to execute echo command.", "blocking": true, "handler" : "../taskhandlers/execHandler", "parameters": { "cmd": "echo 'Congratulations you called a workflow using the API.'" } } } };
processus.execute(wf, function(err, workflow){ if(!err) { console.log(workflow.tasks['task 1'].parameters.stdout); } else { console.log(err); } });
I'm getting below error.
D:\wamp64\www\Demos\processus>node test.js TypeError: Cannot read property 'dataDirectory' of undefined at Object.saveInstance (D:\wamp64\www\Demos\processus\node_modules\processus\engine\persistence\file.js:273:24) at Object.saveInstance (D:\wamp64\www\Demos\processus\node_modules\processus\engine\persistence\store.js:118:35) at realExecute (D:\wamp64\www\Demos\processus\node_modules\processus\engine\processus.js:317:9) at D:\wamp64\www\Demos\processus\node_modules\processus\engine\processus.js:143:11 at executePrePost (D:\wamp64\www\Demos\processus\node_modules\processus\engine\processus.js:193:5) at doPre (D:\wamp64\www\Demos\processus\node_modules\processus\engine\processus.js:172:3) at Object.execute (D:\wamp64\www\Demos\processus\node_modules\processus\engine\processus.js:141:5) at Object.execute (D:\wamp64\www\Demos\processus\node_modules\processus\engine\api.js:67:5) at Object. (D:\wamp64\www\Demos\processus\test.js:18:11)
at Module._compile (module.js:571:32)