Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.hot.status(event => {
if (event === 'abort' || event === 'fail') {
logger.error('HMR error status: ' + event);
// Signal webpack.run.js to do full-reload of the back-end
service.gracefulShutdown(event);
}
// adddintionally when event is idle due to external modules
if (event === 'idle') {
service.gracefulShutdown(event);
}
});
module.hot.accept();
module.hot.accept(['./middleware/graphql'], () => {
logger.debug('loading ./middleware/graphql');
});
// module.hot.accept(['./api/subscriptions'], () => {
onConnect: async (connectionParams, webSocket) => {
logger.debug(`Subscription client connected using built-in SubscriptionServer.`);
const pureContext = await modules.createContext(connectionParams, webSocket);
const contextServices = await serviceContext(connectionParams, webSocket);
return {
...contextServices,
...pureContext,
preferences: defaultPreferences,
update: updateContainers,
};
},
// onDisconnect: () => {},
import { ConsoleLogger, IConsoleLoggerSettings } from '@cdm-logger/server';
import * as Logger from 'bunyan';
const settings: IConsoleLoggerSettings = {
level: 'trace',
};
export const logger: Logger = ConsoleLogger.create('nats-subcscription', settings);
process.on('uncaughtException', ex => {
logger.error(ex);
process.exit(1);
});
public async gracefulShutdown(signal) {
try {
logger.info(`${signal} received. Closing connections, stopping server`);
await this.app.cleanup();
logger.info('Shutting down');
} catch (err) {
logger.error('Error during graceful shutdown');
logger.error(err);
} finally {
process.exit(0);
}
}
}
public async gracefulShutdown(signal) {
try {
logger.info(`${signal} received. Closing connections, stopping server`);
await this.app.cleanup();
logger.info('Shutting down');
} catch (err) {
logger.error('Error during graceful shutdown');
logger.error(err);
} finally {
process.exit(0);
}
}
}
module.hot.dispose(() => {
try {
if (server) {
server.close();
}
} catch (error) {
logger.error(error.stack);
}
});
module.hot.accept(['./website'], () => {
process.on('unhandledRejection', reason => {
logger.error(reason);
});
process.on('unhandledRejection', reason => {
logger.error(reason);
});
const service = new Service();