Files
scrypted/server/src/scrypted-main.ts
2022-01-10 15:25:02 -08:00

25 lines
707 B
TypeScript

import process from 'process';
import semver from 'semver';
import { RPCResultError, startPeriodicGarbageCollection } from './rpc';
import { PluginError } from './plugin/plugin-error';
if (!semver.gte(process.version, '16.0.0')) {
throw new Error('"node" version out of date. Please update node to v16 or higher.')
}
startPeriodicGarbageCollection();
process.on('unhandledRejection', error => {
if (error?.constructor !== RPCResultError && error?.constructor !== PluginError) {
throw error;
}
console.warn('unhandled rejection of RPC Result', error);
});
if (process.argv[2] === 'child') {
require('./scrypted-plugin-main');
}
else {
require('./scrypted-server-main');
}