Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: manage mutagen daemon lifecycle#98

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 18 commits intomainfromethan/mutagen-lifecycle
Mar 12, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedMar 7, 2025
edited
Loading

Closescoder/internal#381.

  • Moves the VPN-specific app files into aVPN folder.
  • Adds an emptyResources folder whose contents are copied into the bundle at build time.
  • Adds aMutagenDaemon abstraction for managing the mutagen daemon lifecycle, this class:
    • Starts the mutagen daemon usingmutagen daemon run, with aMUTAGEN_DATA_DIRECTORY inApplication Support/Coder Desktop/Mutagen, to avoid collisions with a system mutagen using~/.mutagen.
    • Maintains agRPC connection to the daemon socket.
    • Stops the mutagen daemon overgRPC
    • Relays stdout & stderr from the daemon, and watches if the process exits unexpectedly.
    • Handles replacing an orphanedmutagen 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 newFSLib 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 consideringSwiftProtobuf 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 importingSwiftProtobuf 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 overloadVPNLib 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, seeLD_RUNPATH_SEARCH_PATHS. It's not exactly ideal, but I don't think it's worth going to war with XCode over.

TODO

@ethanndicksonGraphite App
Copy link
MemberAuthor

ethanndickson commentedMar 7, 2025
edited
Loading

@@ -4,6 +4,7 @@ import KeychainAccess
import NetworkExtension
import SwiftUI

@MainActor
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

drive-by fix: I believe this is implicit in theObservableObject conformance, but can't hurt to make it explicit.

}

@MainActor
class MutagenDaemon: FileSyncDaemon {
Copy link
MemberAuthor

@ethanndicksonethanndicksonMar 7, 2025
edited
Loading

Choose a reason for hiding this comment

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

Open to suggestions on how to test this. We can easily mock the gRPC calls, but mocking the child process is ???.

I've just done a good amount of manual testing for now.

Comment on lines 53 to 55
// Stop an orphaned daemon, if there is one
try? await connect()
try? await stop()
Copy link
MemberAuthor

@ethanndicksonethanndicksonMar 7, 2025
edited
Loading

Choose a reason for hiding this comment

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

For context,mutagen daemon run acquires a file lock in theMUTAGEN_DATA_DIRECTORY. Multiple instances of the daemon will fail to start, so we need to make sure one isn't running before we start ours. If, for whatever reason, we were unable to kill the daemon, the new one will immediately fail and change theDaemonState.

@ethanndicksonethanndickson self-assigned thisMar 7, 2025
@ethanndicksonethanndickson marked this pull request as ready for reviewMarch 7, 2025 04:06
Copy link
Member

@ThomasK33ThomasK33 left a comment

Choose a reason for hiding this comment

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

The PR looks good on the surface, I'll have to test it locally later and look for edge cases.

@@ -0,0 +1,11 @@
syntax = "proto3";
Copy link
Member

Choose a reason for hiding this comment

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

QQ: Haven't seen a discussion before, but have we considered using the edition2023 version instead of proto3?

@ethanndicksonethanndickson requested review fromThomasK33 andspikecurtis and removed request fordeansheatherMarch 11, 2025 05:28
Copy link
Member

@ThomasK33ThomasK33 left a comment

Choose a reason for hiding this comment

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

LGTM. I think there's an issue in the Coder_DesktopApp.swift file with quitting the VPN on quit

Copy link
Member

@ThomasK33ThomasK33 left a comment

Choose a reason for hiding this comment

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

LGTM

@ethanndicksonGraphite App
Copy link
MemberAuthor

ethanndickson commentedMar 12, 2025
edited
Loading

Merge activity

  • Mar 12, 1:43 AM EDT: A user started a stack merge that includes this pull request viaGraphite.
  • Mar 12, 1:43 AM EDT: A user merged this pull request withGraphite.

@ethanndicksonethanndickson merged commit6f6049e intomainMar 12, 2025
4 checks passed
@ethanndicksonethanndickson deleted the ethan/mutagen-lifecycle branchMarch 12, 2025 05:43
ethanndickson added a commit that referenced this pull requestMar 24, 2025
This makes a few improvements to#98:- The mutagen path & data directory can be now be configured on the MutagenDaemon, to support overriding it in tests (coming soon).- A mutagen daemon failure now kills the process, such that can it be restarted (TBC).- Makes start & stop transitions mutually exclusive via a semaphore, to account for actor re-entrancy.- The start operation now waits for the daemon to respond to a version request before completing.- The daemon is always started on launch, but then immediately stopped if it doesn't manage any file sync sessions, as to not run in the background unncessarily.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ThomasK33ThomasK33ThomasK33 approved these changes

@spikecurtisspikecurtisAwaiting requested review from spikecurtis

Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

manage mutagen daemon lifecycle for coder-desktop-macos
2 participants
@ethanndickson@ThomasK33

[8]ページ先頭

©2009-2025 Movatter.jp