How to use express-graceful-exit - 6 common examples

To help you get started, we’ve selected a few express-graceful-exit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github michaelBenin / react-ssr-spa / src / server / utils / graceful_exit_util.js View on Github external
if (silent) {
    return createOrGetServer().close();
  }

  function gracefulExitCallback() {
    if (config.get('cacheEnabled')) {
      if (redisClient && redisClient.quit) {
        redisClient.quit();
        return process.exit(exitCode);
      }
    }
    return process.exit(exitCode);
  }

  return gracefulExit.gracefulExitHandler(app, createOrGetServer(), {
    log: true,
    logger(data) {
      return log.info(data);
    },
    suicideTimeout: 3 * 1000, // pm2 waits 4 seconds
    exitProcess: false,
    force: true,
    callback: gracefulExitCallback
  });
};
github michaelBenin / react-ssr-spa / src / server / services / express_service.js View on Github external
app.use(responseTime());
app.disable('x-powered-by');

// TODO: configure for specific routes
app.use(helmet());

// TODO: configure for specific routes
app.use(
  contentValidator.validateMax({
    max: MAX_CONTENT_LENGTH_ACCEPTED,
    status: 400,
    message: 'Exceeds Max Content.'
  })
);

app.use(expressGracefulExit.middleware(app));

// TODO: configure for specific routes
app.use(bodyParser.json());

app.use(
  bodyParser.urlencoded({
    extended: false
  })
);

// USED WITH BODY PARSER
// TODO: configure for specific routes
app.use(hpp());

if (env === 'development' || env === 'test') {
  app.use(express.static(path.join(__dirname, '../../static')));
github tanghuibo / eazy-proxy / serve / libs / proxy.js View on Github external
function closeServer(server, app) {
  gracefulExit.init(server);
  app.use(gracefulExit.middleware(app));
  gracefulExit.gracefulExitHandler(app, server, {
    exitProcess: false
  });
}
github tanghuibo / eazy-proxy / serve / libs / proxy.js View on Github external
function closeServer(server, app) {
  gracefulExit.init(server);
  app.use(gracefulExit.middleware(app));
  gracefulExit.gracefulExitHandler(app, server, {
    exitProcess: false
  });
}
github michaelBenin / react-ssr-spa / src / server / services / express_service.js View on Github external
export const createOrGetServer = () => {
  if (!server) {
    server = http.createServer(app);
    expressGracefulExit.init(server);
  }
  return server;
};
github tanghuibo / eazy-proxy / serve / libs / proxy.js View on Github external
function closeServer(server, app) {
  gracefulExit.init(server);
  app.use(gracefulExit.middleware(app));
  gracefulExit.gracefulExitHandler(app, server, {
    exitProcess: false
  });
}

express-graceful-exit

Allow graceful exits for express apps, supporting zero downtime deploys

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis