-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkue.js
41 lines (34 loc) · 1.06 KB
/
kue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var kue = require('kue')
, logger = require('winston')
, redis = require('redis');
/*
*
* The jobs plugin initializes Kue.
*
*/
var Plugin = module.exports = {};
/**
* @param {Number} config.port Port where redis is running
* @param {String} config.host Hostname where the redis instance runs
* @param {Object} config.auth Authentication options for redis
* @param {String} config.webPath Path under which the admin webapp will be mounted
*/
Plugin.attach = function(config) {
kue.redis.createClient = function() {
var client = redis.createClient(config.port, config.host);
client.on('error', function(error) {
logger.error("Error in connection to KUE Redis");
});
client.on('connect', function() {
logger.info("Connection to KUE Redis server open");
})
if (config.auth) {
client.auth(config.auth);
}
return client;
};
this.jobs = kue.createQueue();
if (this.express && config.webPath) {
this.express.after(config.webPath, kue.app);
}
};