|
10 | 10 |
|
11 | 11 | ## Features |
12 | 12 |
|
13 | | - - delayed jobs |
14 | | - - job event and progress pubsub |
15 | | - - rich integrated UI |
16 | | - - infinite scrolling |
| 13 | + - Delayed jobs |
| 14 | + - Job event and progress pubsub |
| 15 | + - Rich integrated UI |
| 16 | + - Infinite scrolling |
17 | 17 | - UI progress indication |
18 | | - - job specific logging |
19 | | - - powered by Redis |
20 | | - - optional retries |
21 | | - - full-text search capabilities |
| 18 | + - Job specific logging |
| 19 | + - Powered by Redis |
| 20 | + - Optional retries |
| 21 | + - Full-text search capabilities |
22 | 22 | - RESTful JSON API |
| 23 | + - Graceful workers shutdown |
23 | 24 |
|
24 | 25 | ## Overview |
25 | 26 |
|
|
34 | 35 | - [Processing Jobs](#processing-jobs) |
35 | 36 | - [Processing Concurrency](#processing-concurrency) |
36 | 37 | - [Updating Progress](#updating-progress) |
| 38 | + - [Graceful Shutdown](#graceful-shutdown) |
37 | 39 | - [Redis Connection Settings](#redis-connection-settings) |
38 | 40 | - [User-Interface](#user-interface) |
39 | 41 | - [JSON API](#json-api) |
@@ -119,7 +121,8 @@ job.progress(frames, totalFrames); |
119 | 121 |
|
120 | 122 | Job-specific events are fired on the `Job` instances via Redis pubsub. The following events are currently supported: |
121 | 123 |
|
122 | | - - `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 |
123 | 126 | - `complete` the job has completed |
124 | 127 | - `promotion` the job (when delayed) is now queued |
125 | 128 | - `progress` the job's progress ranging from 0-100 |
@@ -174,7 +177,7 @@ var email = jobs.create('email', { |
174 | 177 | .save(); |
175 | 178 | ``` |
176 | 179 |
|
177 | | -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. |
178 | 181 |
|
179 | 182 | ```js |
180 | 183 | jobs.promote(); |
@@ -239,9 +242,40 @@ jobs.process('slideshow pdf', 5, function(job, done){ |
239 | 242 | }); |
240 | 243 | ``` |
241 | 244 |
|
| 245 | +### Graceful Shutdown |
| 246 | + |
| 247 | + 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 | + |
242 | 260 | ## Redis Connection Settings |
243 | 261 |
|
244 | | - 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. |
245 | 279 |
|
246 | 280 | For example, to create a Redis client that connects to `192.168.1.2` on port `1234` that requires authentication, use the following: |
247 | 281 |
|
@@ -283,6 +317,15 @@ kue.app.set('title', 'My Application'); |
283 | 317 |
|
284 | 318 | ```js |
285 | 319 | ["5", "7", "10"] |
| 320 | +``` |
| 321 | + You may disable search indexes in `Kue >= 0.7.0` for memory optimization or to avoid probable |
| 322 | + memory leak reported in issue list: |
| 323 | + |
| 324 | +```javascript |
| 325 | +var kue = require('kue'); |
| 326 | +q = kue.createQueue({ |
| 327 | + disableSearch: true |
| 328 | +}); |
286 | 329 | ``` |
287 | 330 |
|
288 | 331 | ### GET /stats |
|
0 commit comments