You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Bug
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
## Feature
- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using [19693](#19693)
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`
## Documentation / Examples
- [ x] Make sure the linting passes by running `yarn lint`
Closes#29959
Copy file name to clipboardExpand all lines: docs/deployment.md
+23Lines changed: 23 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,29 @@ Next.js will automatically load the latest version of your application in the ba
98
98
99
99
**Note:** If a new page (with an old version) has already been prefetched by `next/link`, Next.js will use the old version. Navigating to a page that has _not_ been prefetched (and is not cached at the CDN level) will load the latest version.
100
100
101
+
## Manual Graceful shutdowns
102
+
103
+
Sometimes you might want to run some cleanup code on process signals like `SIGTERM` or `SIGINT`.
104
+
105
+
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.
106
+
107
+
```js
108
+
// pages/_document.js
109
+
110
+
if (process.env.NEXT_MANUAL_SIG_HANDLE) {
111
+
// this should be added in your custom _document
112
+
process.on('SIGTERM', () => {
113
+
console.log('Received SIGTERM: ', 'cleaning up')
114
+
process.exit(0)
115
+
})
116
+
117
+
process.on('SIGINT', () => {
118
+
console.log('Received SIGINT: ', 'cleaning up')
119
+
process.exit(0)
120
+
})
121
+
}
122
+
```
123
+
101
124
## Related
102
125
103
126
For more information on what to do next, we recommend the following sections:
0 commit comments