Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful exit has not taken effect #112

Open
anson09 opened this issue Apr 29, 2024 · 0 comments
Open

Graceful exit has not taken effect #112

anson09 opened this issue Apr 29, 2024 · 0 comments

Comments

@anson09
Copy link

anson09 commented Apr 29, 2024

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,
});
  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant