-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
48 lines (35 loc) · 1.3 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
var cluster = require('cluster')
//--------------------------------------------------------------------------------------------
// cluster
//--------------------------------------------------------------------------------------------
if (cluster.isMaster) {
var clusterWorkerSize = 4;
console.log("master pid %s", process.pid);
for (var i = 0; i < clusterWorkerSize; i++) {
cluster.fork();
}
}
else {
console.log("worker pid %s", process.pid);
//--------------------------------------------------------------------------------------------
// Express
//--------------------------------------------------------------------------------------------
var express = require('express');
var app = express();
app.set('port', 3600);
//--------------------------------------------------------------------------------------------
// Kue
//--------------------------------------------------------------------------------------------
var kue = require('kue');
var jobs = kue.createQueue();
var promote_interval = 100;
jobs.promote(promote_interval);
jobs.process('testJob', 1, require('./jobs/testJob'));
app.use(kue.app);
app.listen(app.get('port'));
// if(cluster.worker.id === 4) {
// var testJob = jobs.create('testJob', {
// title: 'TEST JOB',
// }).save();
// }
}