Skip to content

Commit 7e03553

Browse files
committed
try catch around docker.command("ps");
1 parent 07f08ee commit 7e03553

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

data/processes/addNumbers/launch.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ export async function launch(process_, job, isAsync, parameters, callback) {
178178
let result = {};
179179
result.id = key;
180180

181-
if ((output.schema.type = "number")) result.value = Number(child.stdout);
181+
if ((output.schema.type = "number"))
182+
result.value = Number(child.stdout);
182183

183184
// TODO: what to do??
184185
//if (parameterOutput.transmissionMode == "value") content = result;

data/processes/echoService/launch.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export async function launch(process_, job, isAsync, parameters, callback) {
3131
return callback(
3232
{ code: 400, description: `addNumbersInContainer run only async` },
3333
undefined
34-
);
34+
)
3535
}
3636

3737
job.status = "running"; // accepted, successful, failed, dismissed
@@ -66,22 +66,25 @@ export async function launch(process_, job, isAsync, parameters, callback) {
6666
});
6767
*/
6868

69-
// get running containers
70-
let data = await docker.command("ps");
71-
// is our container already running?
72-
const notFound =
73-
data.containerList.findIndex((element) => element.image == containerName) <
74-
0;
75-
76-
if (notFound) {
77-
const command = `run -d -p ${port}:80 ${containerName}`;
78-
79-
let result = await docker.command(command);
80-
console.log(result);
81-
// give container time to settle
82-
await new Promise((r) => setTimeout(r, 1000));
83-
} else {
84-
console.log(`Container ${containerName} already running. Good.`);
69+
try {
70+
// get running containers
71+
let data = await docker.command("ps")
72+
73+
// is our container already running?
74+
const notFound = data.containerList.findIndex((element) => element.image == containerName) < 0;
75+
if (notFound) {
76+
const command = `run -d -p ${port}:80 ${containerName}`;
77+
78+
let result = await docker.command(command);
79+
console.log(result);
80+
// give container time to settle
81+
await new Promise((r) => setTimeout(r, 1000));
82+
} else {
83+
console.log(`Container ${containerName} already running. Good.`);
84+
}
85+
}
86+
catch (err) {
87+
return callback({ code: 400, description: err.message }, undefined)
8588
}
8689

8790
let content = {};

src/controllers/processes/execution.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ export function post(req, res) {
3535
prefer,
3636
function (err, content, location) {
3737
if (err) {
38-
res
39-
.status(err.code)
40-
.json({ code: err.code, description: err.description });
38+
res.status(err.code)
39+
.json({ code: err.code, description: err.description });
4140
return;
4241
}
4342

0 commit comments

Comments
 (0)