Skip to content

Commit

Permalink
fix: don't start 'mutagen daemon run' during ddev stop/delete (#5868)…
Browse files Browse the repository at this point in the history
… [skip ci]

Co-authored-by: Stanislav Zhuk <stasadev@gmail.com>
  • Loading branch information
rfay and stasadev committed Feb 23, 2024
1 parent d7163e7 commit e5e0238
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/ddevapp/ddevapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2472,9 +2472,11 @@ func (app *DdevApp) Stop(removeData bool, createSnapshot bool) error {
}
}

err = SyncAndPauseMutagenSession(app)
if err != nil {
util.Warning("Unable to SyncAndterminateMutagenSession: %v", err)
if app.IsMutagenEnabled() {
err = SyncAndPauseMutagenSession(app)
if err != nil {
util.Warning("Unable to SyncAndPauseMutagenSession: %v", err)
}
}

if globalconfig.DdevGlobalConfig.IsTraefikRouter() && status == SiteRunning {
Expand Down Expand Up @@ -2509,11 +2511,12 @@ func (app *DdevApp) Stop(removeData bool, createSnapshot bool) error {

// Remove data/database/projectInfo/hosts entry if we need to.
if removeData {
err = TerminateMutagenSync(app)
if err != nil {
util.Warning("Unable to terminate Mutagen session %s: %v", MutagenSyncName(app.Name), err)
if app.IsMutagenEnabled() {
err = TerminateMutagenSync(app)
if err != nil {
util.Warning("Unable to terminate Mutagen session %s: %v", MutagenSyncName(app.Name), err)
}
}

// Remove .ddev/settings if it exists
if fileutil.FileExists(app.GetConfigPath("settings")) {
err = os.RemoveAll(app.GetConfigPath("settings"))
Expand Down
6 changes: 6 additions & 0 deletions pkg/ddevapp/mutagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func MutagenSyncName(name string) string {
// TerminateMutagenSync destroys a Mutagen sync session
// It is not an error if the sync session does not exist
func TerminateMutagenSync(app *DdevApp) error {
if !app.IsMutagenEnabled() {
return nil
}
syncName := MutagenSyncName(app.Name)
if MutagenSyncExists(app) {
_, err := exec.RunHostCommand(globalconfig.GetMutagenPath(), "sync", "terminate", syncName)
Expand All @@ -93,6 +96,9 @@ func PauseMutagenSync(app *DdevApp) error {

// SyncAndPauseMutagenSession syncs and pauses a Mutagen sync session
func SyncAndPauseMutagenSession(app *DdevApp) error {
if !app.IsMutagenEnabled() {
return nil
}
if app.Name == "" {
return fmt.Errorf("no app.Name provided to SyncAndPauseMutagenSession")
}
Expand Down

0 comments on commit e5e0238

Please sign in to comment.