Skip to content

Graceful exit has not taken effect #112

@anson09

Description

@anson09

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions