feat(graceful-shutdown): add enhanced production-ready shutdown sequence#2671
Open
mag123c wants to merge 1 commit intonestjs:masterfrom
Open
feat(graceful-shutdown): add enhanced production-ready shutdown sequence#2671mag123c wants to merge 1 commit intonestjs:masterfrom
mag123c wants to merge 1 commit intonestjs:masterfrom
Conversation
Author
|
ci e2e fail reason: #2672 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What is the current behavior?
Currently, the graceful shutdown mechanism doesn't provide proper support for production environments where readiness and liveness probes need to be handled separately. When a pod receives SIGTERM, there's no way to mark the readiness probe as unhealthy while keeping the liveness probe healthy, which can lead to:
Issue Number: #2569
What is the new behavior?
This PR introduces an enhanced graceful shutdown mechanism with multi-stage shutdown process:
- enableEnhancedShutdown: Enables the enhanced shutdown sequence
- beforeShutdownDelayMs: Time to wait after marking unhealthy (default: 15000ms)
- Stage 1: Mark readiness probe as unhealthy via isApplicationShuttingDown()
- Stage 2: Wait for load balancer to stop routing traffic (configurable delay)
- Stage 3: Process remaining requests for gracefulShutdownTimeoutMs
- Stage 4: Terminate application
- Exported GracefulShutdownService for integration with health checks
- Added isApplicationShuttingDown() method to check shutdown status
Example usage:
Does this PR introduce a breaking change?