eggjs / eggjs/cluster

Graceful exit has not taken effect

Open
#112 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
222
Forks
52
PR merge metrics
No merged PRs in 30d

Description

**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`

```js
// 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";
})

};

```

```js
// index.js
const startCluster = require('egg-cluster').startCluster;

startCluster({
baseDir: __dirname,
workers: 2,
port: 7001,
});
```

1. start command: node index.js
2. find node index.js `pid` in htop
3. curl -v http://127.0.0.1:7001/api/v1/test
4. 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.