Skip to content

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Nov 26, 2025

Related issues

Proposed Changes

  • Implemented studio site stop CLI command for gracefully stopping local WordPress sites
  • Added graceful shutdown mechanism via IPC message to child process with 5s timeout before falling back to PM2 delete
  • Clears latestCliPid from appdata

Testing Instructions

  • Build the CLI: npm run cli:build
  • Create a test site: node dist/cli/main.js site create --path path
  • Stop the site: node dist/cli/main.js site stop --path path
  • Verify the site is stopped and no longer running
  • Verify the latestCliPid is added on start and removed when site is stopped
  • Test error scenarios: try stopping a non-existent site, already stopped site

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@bcotrim bcotrim self-assigned this Nov 26, 2025
@bcotrim bcotrim requested review from a team and fredrikekelund November 26, 2025 17:43
@github-actions
Copy link
Contributor

github-actions bot commented Nov 26, 2025

📊 Performance Test Results

Comparing 3cb5785 vs trunk

site-editor

Metric trunk 3cb5785 Diff Change
load 16402.00 ms 15443.00 ms -959.00 ms 🟢 -5.8%

site-startup

Metric trunk 3cb5785 Diff Change
siteCreation 20163.00 ms 21183.00 ms +1020.00 ms 🔴 5.1%
siteStartup 6939.00 ms 7965.00 ms +1026.00 ms 🔴 14.8%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

Copy link
Contributor

@fredrikekelund fredrikekelund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great overall 👍 My only issues with the implementation were that sendStopMessage was unnecessary, and that we shouldn't use the as keyword for any of the types from cli/lib/types/wordpress-server-ipc.ts. I went ahead and pushed a fix for both of those issues.

There's one more thing I think we should look into before landing this, and that is stopping the proxy server if no remaining running sites depend on it.

Comment on lines 14 to 16
const appdata = await readAppdata();
const site = appdata.sites.find( ( s ) => arePathsEqual( s.path, siteFolder ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use getSiteByFolder here once #2134 has landed.

Comment on lines +53 to +57
builder: ( yargs ) => {
return yargs;
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
builder: ( yargs ) => {
return yargs;
},

@bcotrim bcotrim force-pushed the stu-951-studio-implement-the-studio-site-stop-command branch from e8bc36f to 13095d4 Compare November 27, 2025 17:22
@bcotrim
Copy link
Contributor Author

bcotrim commented Nov 27, 2025

@fredrikekelund thanks for the review! I've updated the code to stop the proxy if no longer needed.
This should be ready for another review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants