fix(apps): cleanup orphaned app processes on daemon restart#818
Open
realkim93 wants to merge 3 commits into
Open
fix(apps): cleanup orphaned app processes on daemon restart#818realkim93 wants to merge 3 commits into
realkim93 wants to merge 3 commits into
Conversation
When the daemon restarts, app subprocesses from the previous session may still be running as orphans. The new AppManager now detects and terminates them during initialization to prevent conflicting robot commands. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
psutil.exe() resolves symlinks, losing the original venv path. Fall back to cmdline[0] which preserves the invocation path and correctly matches *_venv/bin/python patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Test ResultsTested locally on macOS (Darwin 25.2.0, Python 3.12.9). Test 1: Orphaned app process cleanup
Test 2: Daemon self-protection
Test 3: No orphans — no errors
Note on second commitDuring testing, discovered that |
Check for both bin/ (Linux/macOS) and Scripts/ (Windows) when matching app venv python executables. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AppManagerremain running as orphansAppManagerinitializes withcurrent_app = None, unaware of these orphansThis PR adds
_cleanup_orphaned_apps()toAppManager.__init__()that detects and terminates orphaned app processes on startup.Detection criteria (all must match)
_get_venv_parent_dir()*_venv/bin/pythonpattern (.venvexcluded to protect the daemon itself)-m(module execution pattern)Termination strategy
SIGTERMfor graceful shutdown (3-second timeout)_kill_process_tree()+kill()for force termination of survivorsChanges
src/reachy_mini/apps/manager.py: Added_cleanup_orphaned_apps()method + 1-line call in__init__Test plan
🤖 Generated with Claude Code