Skip to content

Commit

Permalink
cmd/syncthing, lib/config: Remove restartOnWakeup option & functional…
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Jul 26, 2022
1 parent 1b575b4 commit a2c5d90
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 261 deletions.
22 changes: 0 additions & 22 deletions cmd/syncthing/main.go
Expand Up @@ -663,8 +663,6 @@ func syncthingMain(options serveOptions) {
}
}

go standbyMonitor(app, cfgWrapper)

if err := app.Start(); err != nil {
os.Exit(svcutil.ExitError.AsInt())
}
Expand Down Expand Up @@ -761,26 +759,6 @@ func resetDB() error {
return os.RemoveAll(locations.Get(locations.Database))
}

func standbyMonitor(app *syncthing.App, cfg config.Wrapper) {
restartDelay := 60 * time.Second
now := time.Now()
for {
time.Sleep(10 * time.Second)
if time.Since(now) > 2*time.Minute && cfg.Options().RestartOnWakeup {
l.Infof("Paused state detected, possibly woke up from standby. Restarting in %v.", restartDelay)

// We most likely just woke from standby. If we restart
// immediately chances are we won't have networking ready. Give
// things a moment to stabilize.
time.Sleep(restartDelay)

app.Stop(svcutil.ExitRestart)
return
}
now = time.Now()
}
}

func autoUpgradePossible(options serveOptions) bool {
if upgrade.DisabledByCompilation {
return false
Expand Down
2 changes: 0 additions & 2 deletions lib/config/config_test.go
Expand Up @@ -62,7 +62,6 @@ func TestDefaultValues(t *testing.T) {
NATLeaseM: 60,
NATRenewalM: 30,
NATTimeoutS: 10,
RestartOnWakeup: true,
AutoUpgradeIntervalH: 12,
KeepTemporariesH: 24,
CacheIgnoredFiles: false,
Expand Down Expand Up @@ -247,7 +246,6 @@ func TestOverriddenValues(t *testing.T) {
NATLeaseM: 90,
NATRenewalM: 15,
NATTimeoutS: 15,
RestartOnWakeup: false,
AutoUpgradeIntervalH: 24,
KeepTemporariesH: 48,
CacheIgnoredFiles: true,
Expand Down

0 comments on commit a2c5d90

Please sign in to comment.