Releases: actionhero/node-resque
v5.3.0: Worker Cleanup by Scheduler
Worker Cleanup by Scheduler
- remove
worker#workerCleanup
- scheduler cleans up workers which stop pinging.
By default, the scheduler will check for workers which haven't pinged redis in 60 minutes. If this happens, we will assume the process crashed, and remove it from redis. If this worker was working on a job, we will place it in the failed queue for later inspection. Every worker has a timer running in which it then updates a key in redis every timeout
(default: 5 seconds). If your job is slow, but async, there should be no problem. However, if your job consumes 100% of the CPU of the process, this timer might not fire.
To modify the 60 minute check, change stuckWorkerTimeout
when configuring your scheudler, ie:
const scheduler = new NodeResque.Scheduler({
stuckWorkerTimeout: (1000 * 60 * 60) // 1 hour, in ms
connection: connectionDetails
})
Set your scheduler's stuckWorkerTimeout = false
to disable this behavior.
const scheduler = new NodeResque.Scheduler({
stuckWorkerTimeout: false // will not fail jobs which haven't pinged redis
connection: connectionDetails
})
Jest
We now test this project with Jest, dropping mocha and should
Test Cleanup
Ensure that connections are properly closed in tests (and other node.js processes)
- Properly close all connections in test suite; prevent node app from shutdown 'hang'.
- Removed
toDisconnectProcessors
as a multiworker option, because it actually wasn't doing anything
(#235)
Misc
- update dependencies
v5.1.0: Locks and BusyBox
v4.0.9
The changes from https://github.com/taskrabbit/node-resque/releases/tag/v5.0.2 are backported to the v4 branch
v5.0.2: PluginRunner Fix
Fixes a bug which prevented plugins defined by a function from being run.
- via #216 by @arunsivasankaran
v5.0.1: faster check for de-duplication in delayed queues
v5.0.0: Async/Await
Version 5.0 rewrites node-resque
to use Async/Await syntax rather than callbacks.
Check out the examples & README for more information on the updated APIs.
Node.js version v8.0.0 and above is now required to run this project.
Breaking Changes
- Every callback-based method API in the package has changed to become an async method.
- Errors now
throw
rather than return anError
object. - You can use try/catch to decide what to do with errors in your project
- for example:
- Errors now
try {
const queue = new NodeResque.Queue({connection: connectionDetails}, jobs)
queue.on('error', function (error) { throw error })
await queue.connect()
} catch (error) {
console.error(`Queue Connection Error: ${error}`)
}
try {
await queue.enqueue('math', 'add', [1, 2])
await queue.enqueue('math', 'add', [1, 2])
await queue.enqueue('math', 'add', [2, 3])
await queue.enqueueIn(3000, 'math', 'subtract', [2, 1])
} catch (error) {
console.error(`Enqueue Error: ${error}`)
}
- Jobs' perform methods should now be async methods that return a response value, for example:
const jobs = {
'Sleep Add': {
plugins: ['JobLock'],
pluginOptions: {
JobLock: {}
},
perform: async (a, b) => {
let answer = a + b
await new Promise((resolve) => { setTimeout(resolve, 1000) })
return answer
}
}
}
- Plugins now inherit from
NodeResque.Plugin
, for example:
const NodeResque = require('node-resque')
class MyPlugin extends NodeResque.Plugin {
beforeEnqueue () {
// console.log("** beforeEnqueue")
return true // should the job be enqueued?
}
afterEnqueue () {
// console.log("** afterEnqueue")
}
beforePerform () {
// console.log("** beforePerform")
return true // should the job be run?
}
afterPerform () {
// console.log("** afterPerform")
}
}
- All classes now follow proper convention of having capitol letter names, ie
NodeResque.Plugin
- Plugin lifecycles are now camel case:
beforeEnqueue
,afterEnqueue
,beforePerform
,afterPerform
- Plugin lifecycle methods are now async methods, with no callback (per the above)
v4.0.8: Ensure that toRun is passed to enqueue even with an error.
If you are enqueuing a job which fails with an error, we weren't properly returning toRun
(which would be false
) as well. We are now!