-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
35 lines (26 loc) · 808 Bytes
/
index.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
const cluster = require('cluster');
const sockmq = require('sockmq');
const sockmqProtocol = 'tcp';// ipc or tcp
const sockmqVerbose = false;
process.sockmq = sockmq;
if (cluster.isMaster) {
sockmq.startServer({ transport: sockmqProtocol, verbose: sockmqVerbose }, () => {
require('./libs/master')();
});
} else {
process
.on('unhandledRejection', (reason, p) => {
console.error(reason, 'Unhandled Rejection at Promise', p);
})
.on('uncaughtException', err => {
console.error(err, 'Uncaught Exception thrown');
process.exit(1);
});
sockmq.connect({
transport:sockmqProtocol,
forkId:process.env.cidr,
verbose:sockmqVerbose
}, () => {
require('./libs/worker')();
});
}