Wait for child process tree shutdown before forcing kill
- add `childTreeGracePeriodMs` constant for shutdown timing - await grace period after `TERM` before sending `KILL` to avoid dev process leaks
This commit is contained in:
1 parent
db94743220
commit
310fd0b187
1 file changed
+5
-3
@@ -14,6 +14,7 @@ const watchedDirectories = [
|
||||
];
|
||||
const forcedShutdownTimeoutMs = 1_500;
|
||||
const restartDebounceMs = 120;
|
||||
const childTreeGracePeriodMs = 1_200;
|
||||
|
||||
await waitOn({
|
||||
resources: [`tcp:${port}`, ...requiredFiles.map((filePath) => `file:${filePath}`)],
|
||||
@@ -183,9 +184,10 @@ async function shutdown(exitCode) {
|
||||
|
||||
await stopApp();
|
||||
killChildTree("TERM");
|
||||
setTimeout(() => {
|
||||
killChildTree("KILL");
|
||||
}, 1_200).unref();
|
||||
await new Promise((resolve) => {
|
||||
setTimeout(resolve, childTreeGracePeriodMs);
|
||||
});
|
||||
killChildTree("KILL");
|
||||
|
||||
process.exit(exitCode);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user