Automattic / breakingbot

breaking incident management chat bot
GNU General Public License v2.0
1 stars 0 forks source link

Fix SIGTERM error on postgres exit #58

Closed katag9k closed 1 month ago

katag9k commented 1 month ago

What

When ts-watch is running process.exitCode = 0 would result in a SIGTERM. Switching to process.exit(0) resolves the issue.

Why

Bug fix and some additional logging added just in case.

How

While developing locally, code changes will reload the app using ts-watch without failing and exiting due to `SIGTERM

mhsdef commented 1 month ago

When ts-watch is running process.exitCode = 0 would result in a SIGTERM.

For posterity, I think it's more the other way around. For unknown to me reasons, ts-watch didn't like the way we were listening on exit and just setting the exit code.

It's not ideal to be explicitly shutting Node down.

In most situations, it is not actually necessary to call process.exit() explicitly. The Node.js process will exit on its own if there is no additional work pending in the event loop. The process.exitCode property can be set to tell the process which exit code to use when the process exits gracefully.

...

Rather than calling process.exit() directly, the code should set the process.exitCode and allow the process to exit naturally by avoiding scheduling any additional work for the event loop:

But, pragmatically, if this fixes it's good enough for me. 👍