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
  • Merge requests
  • !248

Enhance Queue#pause and Queue#resume methods to pause local worker

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/mixmaxhq/add-pauseLocal into master Feb 24, 2016
  • Overview 6
  • Commits 9
  • Pipelines 0
  • Changes 3

Created by: bradvogel

Enhances Queue#pause and Queue#resume methods to pause local workers.

This is useful for graceful shutdown. For example:

process.on('SIGUSR2', function() {
  // Stop processing new jobs.
  queue.pause(true /* Local */);

  // Wait for all currently processing jobs to complete (not covered in this snippet).
  onAllJobsComplete(function(){
    process.exit(1);
  });
});

Let me know if this works! Happy to make changes. I think it's incredibly useful as a step towards supporting graceful shutdown (a la https://github.com/Automattic/kue#graceful-shutdown).

Note that the only part of the API that I'm not completely happy with is that pause(true) only actually pauses after the current promise-loop has expired. So it's possible for another job to get processed after pause(true) has been called. This is usually fine for the graceful shutdown use case above. But perhaps you have a better idea.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/mixmaxhq/add-pauseLocal