Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fastify.register(require('./decorators/raven-decorator'))
fastify.register(require('./decorators/bible-versions-decorator'), { timeout: 0 })
fastify.register(require('./decorators/bible-config-decorator'), { timeout: 0 })
// Plugins
fastify.register(require('./plugins/cors'))
fastify.register(require('./plugins/redirect-authenticated'))
fastify.register(require('./plugins/manifest'))
fastify.register(require('./plugins/service-worker'))
fastify.register(require('./plugins/i18n'))
fastify.register(require('./plugins/bible-versions'))
fastify.register(require('./plugins/bible'))
fastify.register(require('./plugins/confirmations'))
fastify.register(require('./plugins/main'))
const lightship = createLightship()
fastify.log.info('Registering shutdown handler via Lightship')
lightship.registerShutdownHandler(() => {
fastify.log.info('Shutting down Fastify server via registered Lightship handler.')
fastify.close()
})
/* Start Listening on PORT */
const PORT = process.env.PORT || 3030
fastify.listen(PORT, '0.0.0.0', (err) => {
if (err) {
fastify.captureException(err, 'Error starting Fastify server: ')
process.exit(1)
}
lightship.signalReady()
fastify.log.info(`Server started listening on ${fastify.server.address().port}`)
/* global PhusionPassenger */
/* eslint-disable no-console */
const app = require('../app');
const debug = require('debug')('youversion-events:server');
const http = require('http');
const { createLightship } = require('lightship')
const lightship = createLightship()
/**
* Get port from environment and store in Express.
*/
module.exports = function startNodeWWW() {
if (typeof (PhusionPassenger) !== 'undefined') {
PhusionPassenger.configure({ autoInstall: false });
}
/**
* Normalize a port into a number, string, or false.
*/
const normalizePort = (val) => {
if (typeof (PhusionPassenger) !== 'undefined') {
return 'passenger'
} else {
const createLightshipServer = options => {
const lightship = createLightship({
detectKubernetes: true,
...options,
});
lightship.registerShutdownHandler(async () => {
/**
* NOTE: The default k8s grace period is 60 seconds. It is often
* recommended to not exceed the grace period given by k8s by half.
* 20 seconds is chosen here under the assumption that any outstanging
* request just settle by then.
*/
await new Promise(resolve => setTimeout(resolve, 20000));
signalIsNotUp();
if (applicationServer) applicationServer.close();
if (prometheusMetricsServer) prometheusMetricsServer.close();