From b37d49c130eeba33e36f910d2fc7f90e7fda0f96 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Thu, 10 Feb 2022 05:13:27 -0600 Subject: [PATCH] Ensure standalone server handles SIGTERM (#34151) --- packages/next/build/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 00c8d9ece3180..e1c8adf323c37 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -1233,6 +1233,10 @@ const NextServer = require('next/dist/server/next-server').default const http = require('http') const path = require('path') +// Make sure commands gracefully respect termination signals (e.g. from Docker) +process.on('SIGTERM', () => process.exit(0)) +process.on('SIGINT', () => process.exit(0)) + let handler const server = http.createServer(async (req, res) => {