-
Notifications
You must be signed in to change notification settings - Fork 0
manage mutagen daemon lifecycle for coder-desktop-macos #381
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
Comments
Without forking, we won't be able to use To test this, I ran The Mac app already has support for launching on login - on app launch we could just spawn the mutagen daemon as a background process using |
Agreed, let's use |
Closes coder/internal#381. - Moves the VPN-specific app files into a `VPN` folder. - Adds an empty `Resources` folder whose contents are copied into the bundle at build time. - Adds a `MutagenDaemon` abstraction for managing the mutagen daemon lifecycle, this class: - Starts the mutagen daemon using `mutagen daemon run`, with a `MUTAGEN_DATA_DIRECTORY` in `Application Support/Coder Desktop/Mutagen`, to avoid collisions with a system mutagen using `~/.mutagen`. - Maintains a `gRPC` connection to the daemon socket. - Stops the mutagen daemon over `gRPC` - Relays stdout & stderr from the daemon, and watches if the process exits unexpectedly. - Handles replacing an orphaned `mutagen daemon run` process if one exists. This PR does not embed the mutagen binaries within the bundle, it just handles the case where they're present. ## Why is the file sync code in VPNLib? When I had the FileSync code (namely protobuf definitions) in either: - The app target - A new `FSLib` framework target Either the network extension crashed (in the first case) or the app crashed (in the second case) on launch. The crash was super obtuse: ``` Library not loaded: @rpath/SwiftProtobuf.framework/Versions/A/SwiftProtobuf ``` especially considering `SwiftProtobuf` doesn't have a stable ABI and shouldn't be compiled as a framework. At least one other person has ran into this issue when importing `SwiftProtobuf` multiple times: apple/swift-protobuf#1506 (comment) Curiously, this also wasn't happening on local development builds (building and running via the XCode GUI), only when exporting via our build script. ### Solution We're just going to overload `VPNLib` as the source of all our SwiftProtobuf & GRPC code. Since it's pretty big, and we don't want to embed it twice, we'll embed it once within the System Extension, and then have the app look for it in that bundle, see `LD_RUNPATH_SEARCH_PATHS`. It's not exactly ideal, but I don't think it's worth going to war with XCode over. #### TODO - [x] Replace the `Process` with https://github.com/jamf/Subprocess
Daemon Lifecycle
mutagen daemon register
when first file sync is createdmutagen daemon unregister
when last file sync is deleted, or file sync disabled entirely.The text was updated successfully, but these errors were encountered: