Skip to content
Snippets Groups Projects
Commit 450c47ef authored by wactbprot's avatar wactbprot
Browse files

runMp handles ContainerTitle

parent fc491493
Branches
Tags
No related merge requests found
......@@ -15,8 +15,8 @@ var _ = require("underscore")
/**
* ```runMp()``` startet mpdefund wartet bis ready
* an der ctrl api auftaucht
* ```runMp()``` starts container with number ```task.Container``` or
with title ```task.ContainerTitle``` of ```mpdef```.
* @method runMp
* @param {Object} task Task-Objekt
* @param {Function} cb Callback Funktion
......@@ -25,19 +25,31 @@ module.exports = function(task, cb){
var path = task.Path
, mpdef = task.Mp
, cont = task.Container
, ctitle = task.ContainerTitle
, poll = 1000
, ro = {ok: true}
, err
, cpath = [mpdef, cont, "ctrl"];
, err;
mem.get(cpath, function(err, res){
if (_.isUndefined(res)) {
err = new Error("get request to " + cpath.join(".") + " fails");
mem.get([mpdef], function(err, mp){
if (_.isUndefined(mp)) {
err = new Error("get request to " + mpdef + " fails");
log.error(err
, "mp not available");
cb(err);
} else {
mem.set(cpath, [conf.ctrlStr.load, conf.ctrlStr.run].join(";"), function(err){
}
if(ctitle) {
for(var i = 0; i < mp.length; i++) {
if(mp[i].Title == ctitle) {
cont = i;
break;
}
}
}
if(!_.isUndefined(cont)) {
var cpath = [mpdef, cont, "ctrl"]
, cmd = [conf.ctrlStr.load, conf.ctrlStr.run].join(";");
mem.set(cpath, cmd, function(err){
if (!err) {
var inid = setInterval(function(){
mem.get(cpath, function(err, res){
......@@ -49,16 +61,22 @@ module.exports = function(task, cb){
} else {
clearTimeout(inid);
err = new Error("can not get mp below: " + cpath.join("."));
log.error(err);
cb(err);
}
});
}, poll)
} else {
err = new Error("can not set mp below: " + cpath.join("."))
err = new Error("can not set mp below: " + cpath.join("."));
log.error(err);
cb(err);
}
});
} else {
err = new Error("can not find container with title: " + ctitle);
log.error(err);
cb(err);
}
});
}); // get cpath
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment