【文件属性】:
文件名称:koa-graceful-shutdown:确保在关机期间Koa正确返回503
文件大小:58KB
文件格式:ZIP
更新时间:2021-05-01 11:06:57
nodejs koa2 graceful-shutdown JavaScript
koa-优雅关机
确保在关闭期间正确返回HTTP 503 Service Unavailable 。 基于适用于Koa的中间件,实现了的功能。
const http = require ( 'http' ) ;
const Koa = require ( 'koa' ) ;
const shutdown = require ( 'koa-graceful-shutdown' ) ;
const app = new Koa ( ) ;
const server = http . createServer ( app . callback ( ) ) ;
app . use ( shutdown ( server ) ) ;
app . use ( ctx => {
ctx . status = 200 ;
ctx . body = { foo : 'bar' } ;
} ) ;
【文件预览】:
koa-graceful-shutdown-master
----.eslintrc.yml(6KB)
----.gitignore(48B)
----package.json(1KB)
----package-lock.json(213KB)
----index.test.js(7KB)
----index.js(1KB)
----.github()
--------workflows()
----README.md(2KB)
----example.js(869B)
----.eslintignore(54B)
----nodemon.json(208B)
----.editorconfig(147B)