Right Way to End a Process in Sandbox
Created by: it-fm
I would like to know how to terminate the process of a job in progress through another server. I have an express route that gets the id of a job in progress, is there any official or temporary way to finish the job? I really need this kind of resource, because my jobs are too consuming, I have no reason to keep a 5-10 minute job running even after the client cancels it.
Server 1 - API Client:
let job = await queue.getJob(8)
job.discard();
job
.moveToFailed(new Error('cancelled'), true)
Server 2 - Jobs:
queue.process(Job', 2, __dirname + '/job.js')
queue.on('global:failed', function (job, err) {
queue.getJob(job).then(function (job) {
// how to kill?
console.log(job.queue.childPool)
})
})
I have some remarks:
1 - Is using a global event to capture the canceled job correct? Will it not cause failures in case of multiple job instances?
2 - How do I cancel the job using job.queue.childPool
? I tried using process.kill but it ends the task list.