shell: add timeout logic and rework error handling
what's important: * if task code ran, it exits with 0. this code is regardless of (error, result) * when it exited cleanly, we will get the values from the database * if task timed out, the box code kills it and it has a flag tracking timedOut. we can ignore exit code in this case. * if task code was stopped, box code will send SIGTERM which ideally it will handle and end with 70. * if task code crashed and it caught the exception, it will return 50 * if task code crashed and node nuked us, it will exit with 1 * if task code was killed with some unhandleabe signal, taskworker.sh will return the signal (9=SIGKILL)
This commit is contained in:
@@ -31,7 +31,6 @@ describe('Tasks API', function () {
|
||||
expect(response.body.active).to.be(false); // finished
|
||||
expect(response.body.success).to.be(true);
|
||||
expect(response.body.result).to.be('ping');
|
||||
expect(response.body.completed).to.be(true);
|
||||
expect(response.body.error).to.be(null);
|
||||
});
|
||||
|
||||
@@ -63,7 +62,9 @@ describe('Tasks API', function () {
|
||||
|
||||
setTimeout(async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/tasks/${taskId}/stop`)
|
||||
.query({ access_token: owner.token });
|
||||
.query({ access_token: owner.token })
|
||||
.send({})
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.status).to.equal(204);
|
||||
}, 100);
|
||||
@@ -77,7 +78,6 @@ describe('Tasks API', function () {
|
||||
expect(response.body.active).to.be(false); // finished
|
||||
expect(response.body.success).to.be(false);
|
||||
expect(response.body.result).to.be(null);
|
||||
expect(response.body.completed).to.be(true);
|
||||
expect(response.body.error.message).to.contain('stopped');
|
||||
});
|
||||
|
||||
@@ -96,7 +96,6 @@ describe('Tasks API', function () {
|
||||
expect(response.body.tasks[0].active).to.be(false); // finished
|
||||
expect(response.body.tasks[0].success).to.be(true); // finished
|
||||
expect(response.body.tasks[0].result).to.be('ping');
|
||||
expect(response.body.tasks[0].completed).to.be(true);
|
||||
expect(response.body.tasks[0].error).to.be(null);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user