Replace pm2 with homegrown process manager daemon#2712
Open
fredrikekelund wants to merge 12 commits intostu-1301-replace-pm2-axon-with-homegrownfrom
Open
Replace pm2 with homegrown process manager daemon#2712fredrikekelund wants to merge 12 commits intostu-1301-replace-pm2-axon-with-homegrownfrom
fredrikekelund wants to merge 12 commits intostu-1301-replace-pm2-axon-with-homegrownfrom
Conversation
1 task
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
How AI was used in this PR
Codex wrote most of the code in this PR, starting from a detailed list of requirements I shared (based on our experience with pm2). I iterated on this over multiple days, both with Codex and by hand. I've touched all major files in the PR.
process-manager-ipc.tsis a standout example – I made many manual edits there. I've reviewed all the code. The code I've spent the least time editing or reviewing is the tests.Proposed Changes
Tip
I'm happy to pair for a review of this PR. I know it's a big one. Also, please note that this PR builds upon the changes in #2690. That PR should be reviewed first.
See STU-1349 for the "why" of removing pm2. This PR implements the following:
process-manager-daemon.tsthat manages child processes. This involves forking them, tracking them in-memory, forwarding child IPC messages as typed daemon events, and writing stdout/stderr to PM2-compatible log files under~/.studio/pm2/logs. This file is the PM2 replacement.daemon-client.tsreplacespm2-manager.ts. It talks to the daemon over a control socket for request/response commands and an events socket for receiving messages from child processes and process events (online/exit, etc.).The architecture largely follows PM2's example, and
process-manager-daemon.tsimplements the same functionality. A few notes to get reviewers started:daemon-clientexports asendMessageToProcessfunction that uses the process manager "control socket" to send a message with aprocessIdtarget. Whenprocess-manager-daemon.tsreceives the message, it uses the standard Node.js IPC mechanism to forward it to the child process. Child processes cannot respond directly to these messages, but they can emit events through Node.js standard IPC, whichprocess-manager-daemon.tspicks up and broadcasts on the "events socket".daemonBuslistens on the events socket, and thesubscribeSiteEventsfunction picks up theprocess-messageandprocess-eventevents, which are ultimately picked up by_events.ts.Testing Instructions
npm startnode apps/cli/dist/cli/main.js site start --skip-browser --path PATH_TO_SITEin your terminalPre-merge Checklist