Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// If something went wrong loading data sources, log it, tidy up, and die.
console.error(error);
await cleanUpTempDir();
process.exit(2); // eslint-disable-line no-process-exit
}
}
startGateway({
mock,
gateway,
dataSourcePaths,
loadedDataSources,
});
};
cleanup(cleanupOnExit);
nodeCleanup(function (exitCode, signal) {
entries = JSON.stringify(entries, null, '\t');
fs.writeFileSync('entries.json', entries);
if (signal) {
// RECEIVES SIGHUP IF TERMINAL IS CLOSED
console.log('Got signal: ', signal);
console.log('Exiting...');
nodeCleanup.uninstall(); // don't call cleanup handler again
process.kill(process.pid, signal);
return false;
} else {
// console.log('In cleanup. Exit code is', exitCode);
console.log('Exiting...');
}
});
nodeCleanup((exitCode, signal) => {
if (signal) {
console.log('Closing App... ', exitCode, signal); // eslint-disable-line
stopApp();
nodeCleanup.uninstall(); // don't call cleanup handler again
return false;
}
return true;
});
nodeCleanup((_exitCode, signal) => {
tscProcess.kill(signal);
killProcesses(true).then(() => process.exit());
// don't call cleanup handler again
nodeCleanup.uninstall();
return false;
});
nodeCleanup((_exitCode, signal) => {
tscProcess.kill(signal)
killProcesses(true).then(() => process.exit())
// don't call cleanup handler again
nodeCleanup.uninstall()
return false
})
nodeCleanup((exitCode, signal) => {
if (signal) {
logger.info(`Closing App... exitCode: ${exitCode} signal: ${signal}`);
stopApp(signal);
nodeCleanup.uninstall(); // don't call cleanup handler again
return false;
}
return true;
});
export default (_, signal) => {
// Uninstall the handler to prevent an infinite loop.
cleanup.uninstall();
// Delete the temporary directory.
const shouldPrintShutdownMessage = cleanUpTempDir();
if (shouldPrintShutdownMessage) {
success('Successfully shut down. Thanks for using GrAMPS!');
}
process.kill(process.pid, signal);
return false;
};
.then(() => {
nodeCleanup.uninstall();
})
.catch(() => {
let stopped = Object.values(server.stop());
Promise.all(stopped)
.then(
val => {
logger.info(
"index.js: Cleaned all resources. Shutting down."
);
},
err => {
logger.error(`index.js: ${err}`);
}
)
.then(() => {
process.kill(process.pid, signal);
});
NodeCleanup.uninstall();
return false;
}
});