Unverified Commit 8366f1af authored by Michael Novotny's avatar Michael Novotny Committed by GitHub

docs: Clarify manual graceful shutdown in dev server (#51078)

Replaces #50481

---------
Co-authored-by: 's avatarDelba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
Co-authored-by: 's avatarLee Robinson <me@leerob.io>
parent e797546e
...@@ -134,14 +134,16 @@ Next.js will automatically load the latest version of your application in the ba ...@@ -134,14 +134,16 @@ Next.js will automatically load the latest version of your application in the ba
## Manual Graceful shutdowns ## Manual Graceful shutdowns
Sometimes you might want to run some cleanup code on process signals like `SIGTERM` or `SIGINT`. When self-hosting, you might want to run code when the server shuts down on `SIGTERM` or `SIGINT` signals.
You can do that by setting the env variable `NEXT_MANUAL_SIG_HANDLE` to `true` and then register a handler for that signal inside your `_document.js` file. Please note that you need to register env variable directly in the system env variable, not in the `.env` file. You can set the env variable `NEXT_MANUAL_SIG_HANDLE` to `true` and then register a handler for that signal inside your `_document.js` file. You will need to register the env variable directly in the `package.json` script, not in the `.env` file.
> **Note**: Manual signal handling is not available in `next dev`.
```json filename="package.json" ```json filename="package.json"
{ {
"scripts": { "scripts": {
"dev": "NEXT_MANUAL_SIG_HANDLE=true next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"start": "NEXT_MANUAL_SIG_HANDLE=true next start" "start": "NEXT_MANUAL_SIG_HANDLE=true next start"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment