forked from nodecg/nodecg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (31 loc) · 974 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
36
37
38
39
'use strict';
global.exitOnUncaught = true;
if (process.cwd() !== __dirname) {
console.warn('[nodecg] process.cwd is %s, expected %s', process.cwd(), __dirname);
process.chdir(__dirname);
console.info('[nodecg] Changed process.cwd to %s', __dirname);
}
const semver = require('semver');
const nodeVersion = process.versions.node;
if (!semver.satisfies(nodeVersion, '>=6')) {
console.error('ERROR: NodeCG requires Node.js >=6 and npm >=2');
console.error(` Your Node.js version: v${nodeVersion}`);
process.exit(1);
}
process.on('uncaughtException', err => {
if (!global.rollbarEnabled) {
if (global.exitOnUncaught) {
console.error('UNCAUGHT EXCEPTION! NodeCG will now exit.');
} else {
console.error('UNCAUGHT EXCEPTION!');
}
console.error(err);
if (global.exitOnUncaught) {
process.exit(1);
}
}
});
const server = require('./lib/server')
.on('error', () => process.exit(1))
.on('stopped', () => process.exit(0));
server.start();