smartfacecloud-emulator-dispatcher
Version:
Handles Emulator Dispatcher Part of SmartfaceCloud
49 lines (42 loc) • 1.23 kB
JavaScript
if (global.v8debug) {
global.v8debug.Debug.setBreakOnUncaughtException();
}
global.shared = {
response: {}
};
const init = require('../src/index').init;
const args = require('minimist')(process.argv.slice(2));
const LogToConsole = require("../src/common/LogToConsole");
const opts = convertCLIArgsToOpts(args);
var log;
init(opts);
function convertCLIArgsToOpts(args) {
var opts = {
meta: {},
ports: {}
};
opts.meta.logToConsole = !!args.logToConsole || !!args.logtoconsole || !!args.verbose;
opts.meta.restart = !!args.restart;
opts.meta.v = !!args.v;
opts.meta.bypassSecurityCheck = !!args.bypasssecuritycheck || !!args.bypassSecurityCheck;
args.port && (opts.ports.dispatcher = args.port);
log = new LogToConsole(opts.meta.logToConsole, '[PROCESS]').log;
return opts;
}
process.on('uncaughtException', (err) => {
log && log(JSON.stringify({
err: "Uncaught Exception",
stack: err.stack && err.stack.toString(),
msg: err.toString()
}, null, "\t"));
process.exit(1);
});
process.on('unhandledRejection', (err) => {
log && log(JSON.stringify({
err: "Unhandled Rejection",
stack: err.stack && err.stack.toString(),
msg: err.toString()
}, null, "\t"));
process.exit(1);
});