-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(webserver): customize shutdown with new kill
option
#34130
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Dmitry Gozman <[email protected]> Signed-off-by: Simon Knott <[email protected]>
This comment has been minimized.
This comment has been minimized.
Test results for "tests 1"1 failed 4 flaky37414 passed, 654 skipped Merge workflow run. |
@@ -37,6 +37,7 @@ export default defineConfig({ | |||
| `stdout` | If `"pipe"`, it will pipe the stdout of the command to the process stdout. If `"ignore"`, it will ignore the stdout of the command. Default to `"ignore"`. | | |||
| `stderr` | Whether to pipe the stderr of the command to the process stderr or ignore it. Defaults to `"pipe"`. | | |||
| `timeout` | How long to wait for the process to start up and be available in milliseconds. Defaults to 60000. | | |||
| `kill` | How to shut down the process gracefully. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ SIGINT: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd split it into 2 fields{ signal: SIGINT', timeout 5000 }
to make it clear that only one signal can be specified and what the value semantics is.
|
||
return new Promise<void>((resolve, reject) => { | ||
const timer = timeout !== 0 | ||
? setTimeout(() => reject(new Error(`process didn't close gracefully within timeout, falling back to SIGKILL`)), timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop 'falling back to SIGKILL' as it makes an assumption about the caller and how it handles errors. We already print <will force kill>
before sending sigkill, so it should be clear.
@@ -226,7 +226,7 @@ export async function launchProcess(options: LaunchProcessOptions): Promise<Laun | |||
killSet.delete(killProcessAndCleanup); | |||
removeProcessHandlersIfNeeded(); | |||
options.log(`[pid=${spawnedProcess.pid}] <kill>`); | |||
if (spawnedProcess.pid && !spawnedProcess.killed && !processClosed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we wouldn't send the signal again if it has already been received, I believe it shouldn't matter for SIGKILL handling, but would be nice to double check.
We had this change up earlier, but it staled because I was unsure what PID to signal. After doing some more research on it, it appears that both for
SIGINT
andSIGTERM
it's appropriate to send to the entire process group. So this PR is a reopening of #33379 with those learnings.Closes #33377, #18209