You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8d0bf30
Browse filesBrowse the repository at this point in the historyBrowse files
Job-specific events are fired on the `Job` instances via Redis pubsub. The following events are currently supported:
119
123
120
-
- `failed` the job has failed
124
+
- `failed` the job has failed and has no remaining attempts
125
+
- 'failed attempt' the job has failed, but has remaining attempts yet
121
126
- `complete` the job has completed
122
127
- `promotion` the job (when delayed) is now queued
123
128
- `progress` the job's progress ranging from 0-100
@@ -167,12 +172,12 @@ var email = jobs.create('email', {
167
172
title:'Account renewal required'
168
173
, to:'tj@learnboost.com'
169
174
, template:'renewal-email'
170
-
}).delay(minute)
175
+
}).delay(milliseconds)
171
176
.priority('high')
172
177
.save();
173
178
```
174
179
175
-
When using delayed jobs, we must also check the delayed jobs with a timer, promoting them if the scheduled delay has been exceeded. This `setInterval` is defined within `Queue#promote(ms)`, defaulting to a check every 5 seconds.
180
+
When using delayed jobs, we must also check the delayed jobs with a timer, promoting them if the scheduled delay has been exceeded. This `setInterval` is defined within `Queue#promote(ms,limit)`, defaulting to a check of top 200 jobs every 5 seconds.
176
181
177
182
```js
178
183
jobs.promote();
@@ -182,7 +187,8 @@ jobs.promote();
182
187
183
188
Processing jobs is simple with Kue. First create a `Queue` instance much like we do for creating jobs, providing us access to redis etc, then invoke `jobs.process()` with the associated type.
184
189
185
-
In the following example we pass the callback `done` to `email`, if this function responds with an error it will be displayed in the UI and the job will be marked as a failure.
190
+
In the following example we pass the callback `done` to `email`, When an error occurs we invoke `done(err)` to tell Kue something happened, otherwise we invoke `done()` only when the job is complete.
191
+
if this function responds with an error it will be displayed in the UI and the job will be marked as a failure.
We can access this same arbitrary data within a separate process while processing, via the `job.data` property. In the example we render each slide one-by-one, updating the job's log and process. When an error occurs we invoke `done(err)` to tell Kue something happened, otherwise we invoke `done()` only when the job is complete.
223
+
We can access this same arbitrary data within a separate process while processing, via the `job.data` property. In the example we render each slide one-by-one, updating the job's log and process.
As of Kue 0.7.0, a `Queue#shutdown(fn, timeout)` is added which signals all workers to stop processing after
248
+
their current active job is done. Workers will wait `timeout` milliseconds for their active job's done to be called
249
+
or mark the active job `failed` with shutdown error reason. When all workers tell Kue they are stopped `fn` is called.
250
+
251
+
```javascript
252
+
process.once( 'SIGTERM', function ( sig ) {
253
+
queue.shutdown(function(err) {
254
+
console.log( 'Kue is shut down.', err||'' );
255
+
process.exit( 0 );
256
+
}, 5000 );
257
+
});
258
+
```
259
+
239
260
## Redis Connection Settings
240
261
241
-
By default, Kue will connect to Redis using the client default settings (port defaults to `6379`, host defaults to `127.0.0.1`). Redis client connection settings can be set by overriding the `kue.redis.createClient` function.
262
+
By default, Kue will connect to Redis using the client default settings (port defaults to `6379`, host defaults to `127.0.0.1`).
263
+
`Queue#createQueue(options)` accepts redis connection options in `options.redis` key.
264
+
265
+
```javascript
266
+
var kue =require('kue');
267
+
q =kue.createQueue({
268
+
redis: {
269
+
port:1234,
270
+
host:'10.0.50.20'
271
+
options: {
272
+
// look for more redis options in [node_redis](https://github.com/mranney/node_redis)
273
+
}
274
+
}
275
+
});
276
+
```
277
+
278
+
For backward compatibility to `Kue < 0.7.0`, monkey-patch-styled Redis client connection settings can be set by overriding the `kue.redis.createClient` function.
242
279
243
280
For example, to create a Redis client that connects to `192.168.1.2` on port `1234` that requires authentication, use the following:
0 commit comments