Always kill PM2 daemon when running site stop --all#2683
Open
Always kill PM2 daemon when running site stop --all#2683
site stop --all#2683Conversation
When no sites are running, the daemon should still be killed to prevent stale processes from persisting, particularly in development where the daemon may retain hardcoded paths to node_modules that become invalid.
site stop --all
epeicher
approved these changes
Feb 27, 2026
Contributor
epeicher
left a comment
There was a problem hiding this comment.
Thanks for fixing this @gcsecsey! I have been able to reproduce this on trunk by starting Studio and quickly quitting before the sites start. At that point, the pm2 processes are kept there. This is not happening on this branch, so this LGTM! ![]()
| Trunk | This branch |
|---|---|
![]() |
![]() |
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.


Related issues
I ran into an issue while working on Studio from multiple workspaces. Each workspace has its own node_modules, and when the PM2 daemon was started from one workspace, it retained hardcoded paths to that workspace’s node_modules. When I switched to a different workspace (or the original one was removed/changed), the stale daemon would fail to fork child processes with
MODULE_NOT_FOUNDerrors because those paths no longer existed.Studio’s quit handler calls
site stop --all, but if no sites are actively running at quit time, the command returns early without killing the PM2 daemon. The daemon would then linger with outdated module paths baked in, breaking subsequent launches from other workspaces.Proposed Changes
killDaemonAndChildrenAndExitProcess()whensite stop --allis invoked, even if no sites are runningTesting Instructions
npx pm2 listshould show an empty tablePre-merge Checklist