-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (27 loc) · 915 Bytes
/
index.js
File metadata and controls
32 lines (27 loc) · 915 Bytes
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
const cluster = require('cluster');
const Sentry = require('@sentry/node');
const Master = require('./cluster/Master');
const Worker = require('./cluster/Worker');
const Logger = require('./util/log/Logger');
class pxlAPI {
constructor() {
if (!process.env.NODE_ENV)
process.env.NODE_ENV = 'dev';
if (!['dev', 'test', 'production'].includes(process.env.NODE_ENV))
throw new Error('Invalid Node environment');
if (process.env.NODE_ENV !== 'dev') {
Sentry.init({
dsn: 'https://c0f9b0fdeb414b97a71df17b06ad4121@o499021.ingest.sentry.io/5577101',
environment: process.env.NODE_ENV
});
}
process.setMaxListeners(0);
process.on('warning', warning => Logger.warn(warning));
process.on('unhandledRejection', reason => Logger.error('Unhandled promise rejection', reason));
if (cluster.isMaster)
void Master.run();
else
void Worker.run();
}
}
module.exports = new pxlAPI();