Skip to content

Commit

Permalink
docs: clarify how to handle SIGUSR2
Browse files Browse the repository at this point in the history
Fixes #1889
  • Loading branch information
remy committed Jun 20, 2024
1 parent 6020968 commit d7cfe08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,10 @@ nodemon sends a kill signal to your application when it sees a file update. If y
The following example will listen once for the `SIGUSR2` signal (used by nodemon to restart), run the clean up process and then kill itself for nodemon to continue control:

```js
process.once('SIGUSR2', function () {
// important to use `on` and not `once` as nodemon can re-send the kill signal
process.on('SIGUSR2', function () {
gracefulShutdown(function () {
process.kill(process.pid, 'SIGUSR2');
process.kill(process.pid, 'SIGTERM');
});
});
```
Expand Down
4 changes: 3 additions & 1 deletion faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,10 @@ Your application will likely be running the old version code if you see that mes
A common cause for this is when graceful shutdowns are doing async tasks, i.e:

```
process.once('SIGUSR2', async () => {
// ensure this is `on` and not `once`
process.on('SIGUSR2', async () => {
await db.disconnect()
process.kill(process.pid, 'SIGTERM');
})
```

Expand Down

0 comments on commit d7cfe08

Please sign in to comment.