-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
52 lines (43 loc) · 1.08 KB
/
server.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
42
43
44
45
46
47
48
49
50
51
52
var express = require('express');
var kue = require('kue');
var ui = require('kue-ui');
var log = require('bole')('kueui');
module.exports = server;
function server (config) {
config.get('redis.socket')
? kue.createQueue({
prefix: 'queue',
redis: {
socket: config.get('redis.socket'),
auth: config.get('redis.password')
}
})
: kue.createQueue({
prefix: 'queue',
redis: {
port: config.get('redis.port'),
host: config.get('redis.host'),
auth: config.get('redis.password')
}
});
var app = express();
ui.setup({
apiURL: '/api',
baseURL: '/ui',
updateInterval: parseInt(config.get('updateinterval'), 10)
});
app.use('/api/', kue.app);
app.use('/ui', ui.app);
function start () {
app.listen(parseInt(config.get('port'), 10), config.get('address'), function (err) {
if (err) {
log.error(err);
process.exit(1);
}
log.info('listening on', config.get('address') + ':' + config.get('port'));
});
}
return {
start: start
};
}