express Graceful Shutdown 的几种方法

内容主要来自官方文档

几种方法

  • 进程管理模式
const server = app.listen(port)
process.on('SIGTERM', () => {
  debug('SIGTERM signal received: closing HTTP server')
  server.close(() => {
    debug('HTTP server closed')
  })
})
  • 外部依赖库
    @godaddy/terminus,lightship,http-terminator,express-actuator

说明

几个外部库是一个很不错的选择,内容主要来自express 官方,对于实际使用还是比较有价值的

参考资料

https://expressjs.com/en/advanced/healthcheck-graceful-shutdown.html
https://github.com/rcruzper/express-actuator
https://github.com/gajus/http-terminator
https://github.com/gajus/lightship
https://github.com/godaddy/terminus

原文地址:https://www.cnblogs.com/rongfengliang/p/15373331.html