Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
delete newAdmins[username];
// This is needed to make admins dirty and update db
pipeline.admins = newAdmins;
return pipeline.update();
}
// Add user as admin if permissions good and does not already exist
if (!pipeline.admins[username]) {
newAdmins[username] = true;
// This is needed to make admins dirty and update db
pipeline.admins = newAdmins;
return pipeline.update();
}
} catch (err) {
logger.info(err.message);
}
return Promise.resolve();
}
const gracefulStop = async () => {
try {
logger.info('gracefully shutting down server');
await server.root.stop({
timeout: 5000
});
process.exit(0);
} catch (err) {
logger.error(err);
process.exit(1);
}
};
task: () => new Promise(async (resolve) => {
await server.app.jobFactory.cleanUp();
logger.info('completed clean up tasks');
resolve();
})
});
const onSigterm = async () => {
try {
logger.info('got SIGTERM; running triggers before shutdown');
const res = await promiseTimeout(taskHandler(), options.terminationGracePeriod * 1000);
if (res) {
logger.error(res);
}
await gracefulStop();
} catch (err) {
logger.error(err);
}
};