pandora
Version:
A powerful and lightweight application manager for Node.js applications powered by TypeScript.
52 lines • 1.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const wrap = require('pandora-spawn-wrap');
const SpawnWrapperUtils_1 = require("./SpawnWrapperUtils");
const pandora_dollar_1 = require("pandora-dollar");
const const_1 = require("../const");
const CoreSDKWithExtendedConfig_1 = require("../util/CoreSDKWithExtendedConfig");
async function main() {
SpawnWrapperUtils_1.SpawnWrapperUtils.increaseLevel();
if (!SpawnWrapperUtils_1.SpawnWrapperUtils.decideFollow()) {
// unwrap it
if (wrap.lastUnwrap) {
wrap.lastUnwrap(true);
}
}
if (process.argv[2].endsWith('/npm')) {
wrap.runMain();
return;
}
try {
const processRepresentation = JSON.parse(process.env[const_1.PANDORA_PROCESS]);
const { appName, appDir } = processRepresentation;
const coreSdk = new CoreSDKWithExtendedConfig_1.CoreSDKWithExtendedConfig({
mode: 'worker',
appName, appDir
});
// TODO: facade require('pandora') also needs in version 2
await coreSdk.start();
}
catch (err) {
pandora_dollar_1.consoleLogger.error(err);
}
// unref all active handles
// after node.js v11, Timer objects no longer show up in process._getActiveHandles()
// see: https://github.com/nodejs/node/issues/25806
try {
for (const handler of process._getActiveHandles()) {
try {
handler.unref();
}
catch (err) {
// ignore
}
}
}
catch (err) {
// ignore
}
wrap.runMain();
}
main().catch(pandora_dollar_1.consoleLogger.error.bind(pandora_dollar_1.consoleLogger));
//# sourceMappingURL=spawnWrapper.js.map