Skip to content

Queue.pause

Grant Carthew edited this page Sep 29, 2016 · 3 revisions

Method Signature

Queue.pause(global)

Parameter: global Boolean

  • true for a global queue pause, false or undefined to only pause the local Queue object.

Returns: Promise => true

  • Will only ever resolve to true.

Example:

q.pause().then(() => {
  // The Queue object is now paused
}).catch(err => console.error(err))

Description

Use the Queue.pause method for pausing either the entire queue or just the local Queue object. After calling Queue.pause your code will wait until all running jobs being processed by the local Queue object have finished before resolving the Promise. This could take some time depending on your jobs.

To globally pause the queue, pass the global parameter as true. This will cause the Queue object to write a state document to the queue database table causing a change feed to be sent to all Queue objects connected to the same queue. Once a Queue object receives this global pause event it will transition to a pause state. Again, each Queue objects will remain in a pausing state until all running jobs have completed.

To resume the Queue objects call the Queue.resume method.

Warning: It is possible for you to send a global pause causing all Queue objects to enter a pause state, and then only resume the local Queue object.

If you are wanting to stop the queue gracefully, try Queue.stop instead of Queue.pause.

Main

How It Works

Contributing

API

Queue Methods

Queue Properties

Queue Events

Job Methods

Job Properties

Documentation

Clone this wiki locally