Skip to content

Commit

Permalink
Merge pull request #1 from vercel/canary
Browse files Browse the repository at this point in the history
docs: Clarify manual graceful shutdown in dev server (vercel#51078)
  • Loading branch information
dhruv-kaushik committed Jun 10, 2023
2 parents 43cb577 + 8366f1a commit 510c409
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -134,14 +134,16 @@ Next.js will automatically load the latest version of your application in the ba

## 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"
{
"scripts": {
"dev": "NEXT_MANUAL_SIG_HANDLE=true next dev",
"dev": "next dev",
"build": "next build",
"start": "NEXT_MANUAL_SIG_HANDLE=true next start"
}
Expand Down

0 comments on commit 510c409

Please sign in to comment.