Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #1432
Closed
Open
Issue created Aug 19, 2019 by Administrator@rootContributor

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.

Assignee
Assign to
Time tracking