-
Notifications
You must be signed in to change notification settings - Fork 53
Ensure all CLI commands can be aborted #2282
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
Ensure all CLI commands can be aborted #2282
Conversation
| process.on( 'exit', disconnect ); | ||
| process.on( 'SIGINT', disconnect ); | ||
| process.on( 'SIGTERM', disconnect ); | ||
|
|
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.
This isn't necessary. API consumers should be responsible for connecting and disconnecting from pm2. In fact, this previously resulted in a race condition where the abort message I implemented in this PR wouldn't be delivered (because the process disconnected from the pm2 daemon before sending it).
|
|
||
| const managerMessageStopServer = z.object( { | ||
| topic: z.literal( 'stop-server' ), | ||
| data: z.object( {} ), |
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.
pm2 requires all messages to have id, topic, and data fields. We didn't notice that the stop-server topic would generate errors because stopWordPressServer swallows exceptions.
bcotrim
left a comment
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.

Related issues
Proposed Changes
AbortControllerincli/lib/wordpress-server-manager.tsthat interruptssendMessagepromises, ensuring that the CLI process exits when it receives aSIGINTorSIGTERM(Ctrl+C)abortIPC message topic that aborts async operations incli/lib/types/wordpress-server-ipc.ts(most oftenly killing the process). We'll refine this behavior once Re-enable WP-CLI execution in the child process #2261 has landed.Testing Instructions
npm run cli:buildnode dist/cli/main.js site create --path PATH_TO_SITEwherePATH_TO_SITEis the path to a new folder where the site should be createdStarting WordPress serverstage, press Ctrl+CPre-merge Checklist