Terminate app process group on exit#1602
Conversation
Signed-off-by: Albert Callarisa <albert@diagrid.io>
There was a problem hiding this comment.
Pull request overview
Updates dapr run shutdown behavior to terminate the entire application process group (so grandchild processes like those spawned by go run don’t get orphaned), improving reliability of dapr stop/shutdown flows.
Changes:
- Introduces an OS-specific
killProcessGroup(*os.Process)helper (Unix: process-group signaling; Windows: delegates toProcess.Kill). - Replaces direct
Process.Kill()calls withkillProcessGroup()when stopping the app incmd/run.go. - Adds Unix implementation that targets the app’s process group to terminate grandchildren.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cmd/run_unix.go |
Adds Unix killProcessGroup implementation using Getpgid and group signaling. |
cmd/run_windows.go |
Adds Windows killProcessGroup stub delegating to Process.Kill. |
cmd/run.go |
Switches app termination logic to use killProcessGroup in two shutdown paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: Albert Callarisa <albert@diagrid.io>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Albert Callarisa <albert@diagrid.io>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Albert Callarisa <albert@diagrid.io>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Albert Callarisa <albert@diagrid.io>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Albert Callarisa <albert@diagrid.io>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1602 +/- ##
==========================================
- Coverage 15.45% 15.43% -0.03%
==========================================
Files 64 64
Lines 7220 7230 +10
==========================================
Hits 1116 1116
- Misses 6018 6028 +10
Partials 86 86 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Albert Callarisa <albert@diagrid.io>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Not an interesting network failure, looks good |
* Kill app process group when stopping Signed-off-by: Albert Callarisa <albert@diagrid.io> * Address copilot comments Signed-off-by: Albert Callarisa <albert@diagrid.io> * Addressed copilot comments Signed-off-by: Albert Callarisa <albert@diagrid.io> * Addressed copilot comments Signed-off-by: Albert Callarisa <albert@diagrid.io> * Addressed copilot comments Signed-off-by: Albert Callarisa <albert@diagrid.io> * Addressed copilot comments Signed-off-by: Albert Callarisa <albert@diagrid.io> * Addressed copilot comments Signed-off-by: Albert Callarisa <albert@diagrid.io> --------- Signed-off-by: Albert Callarisa <albert@diagrid.io> (cherry picked from commit 35cba49)
* Kill app process group when stopping * Address copilot comments * Addressed copilot comments * Addressed copilot comments * Addressed copilot comments * Addressed copilot comments * Addressed copilot comments --------- (cherry picked from commit 35cba49) Signed-off-by: Albert Callarisa <albert@diagrid.io> Co-authored-by: Albert Callarisa <albert@diagrid.io>
When running an app that spawns other child processes (like
go rundoes) we need to make sure we kill the whole group and not just the parent.The current implementation leaves the child process orphan, so in some cases like a
go runit means the app doesn't really stop when using adapr stopcommand. This PR fixes it by killing the whole process tree.