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

Support graceful shutdowns #36909

Merged
merged 8 commits into from May 16, 2022
11 changes: 10 additions & 1 deletion packages/next/bin/next.ts
Expand Up @@ -129,7 +129,16 @@ if (process.versions.pnp === '3') {
}

// Make sure commands gracefully respect termination signals (e.g. from Docker)
process.on('SIGTERM', () => process.exit(0))
// Allow the graceful termination to be manually configurable
if (!process.env.NEXT_MANUAL_SIGTERM) {
process.on('SIGTERM', () =>
setTimeout(
() => process.exit(0),
parseInt(process.env.NEXT_GRACEFUL_SHUTDOWN_TIMEOUT_MS || '0', 10)
ijjk marked this conversation as resolved.
Show resolved Hide resolved
)
ijjk marked this conversation as resolved.
Show resolved Hide resolved
)
}

process.on('SIGINT', () => process.exit(0))

commands[command]()
Expand Down