This repository was archived by the owner on Dec 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (41 loc) · 1.33 KB
/
index.js
File metadata and controls
49 lines (41 loc) · 1.33 KB
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
#!/usr/bin/env node
/* eslint-disable no-console */
const TITLE = 'cp-zen-platform';
process.env.component = TITLE;
process.setMaxListeners(0);
require('events').EventEmitter.prototype._maxListeners = 100; // eslint-disable-line no-underscore-dangle
const util = require('util');
const bin = require('./web/index.js');
// clean shut down - note cb is optional here (used in testsuite)
function cleanShutdown() {
console.log(`Process: ${process.pid} exiting`);
process.exit(0);
}
// Show 'starting' message
let starting = `Starting ${TITLE} `;
starting += `Master: ${process.pid}`;
console.log(starting);
// handle uncaught exceptions
process.on('uncaughtException', err => {
if (err !== undefined) {
const error = {
date: new Date().toString(),
msg:
err.stack !== undefined
? `FATAL: UncaughtException, please report: ${util.inspect(
err.stack
)}`
: 'FATAL: UncaughtException, no stack trace',
err: util.inspect(err),
};
console.error(JSON.stringify(error));
}
cleanShutdown(); // exit on uncaught exception
});
process.on('unhandledRejection', r => console.log(r));
// handle process signals
process.on('SIGTERM', cleanShutdown);
process.on('SIGHUP', cleanShutdown);
process.on('SIGINT', cleanShutdown);
process.on('SIGUSR2', cleanShutdown);
bin.start();