egg-cluster
egg-cluster copied to clipboard
Graceful exit has not taken effect
Version: system: macOS 14.4.1 node: 20.12.2 "egg": "^3.17.5", "egg-cluster": "^2.2.1",
Minimal Code Example:
npx egg-init --type simple
// router.js
module.exports = app => {
const { router, controller } = app;
router.get('/', controller.home.index);
// add a router has a 3 seconds aysnc job
router.get("/test", async (ctx) => {
await new Promise((resolve) => {
setTimeout(() => {
resolve(1);
}, 3000);
});
ctx.body = "test";
})
};
// index.js
const startCluster = require('egg-cluster').startCluster;
startCluster({
baseDir: __dirname,
workers: 2,
port: 7001,
});
- start command: node index.js
- find node index.js
pidin htop - curl -v http://127.0.0.1:7001/api/v1/test
- send SIGTERM signal to pid filter in step 2
Expected: The request in step 3 has a successful response, EGG server closes after handling in transit connection.
Actually: the connection is closed immediately after the SIGTERM signal send.