mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
cmd/syncthing, etc: Consistent failure restart backoff (#7439)
This commit is contained in:
parent
310fba4c12
commit
587c89d979
@ -36,8 +36,9 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
countRestarts = 4
|
||||
loopThreshold = 60 * time.Second
|
||||
restartCounts = 4
|
||||
restartPause = 1 * time.Second
|
||||
restartLoopThreshold = 60 * time.Second
|
||||
logFileAutoCloseDelay = 5 * time.Second
|
||||
logFileMaxOpenTime = time.Minute
|
||||
panicUploadMaxWait = 30 * time.Second
|
||||
@ -84,7 +85,7 @@ func monitorMain(options serveOptions) {
|
||||
}
|
||||
|
||||
args := os.Args
|
||||
var restarts [countRestarts]time.Time
|
||||
var restarts [restartCounts]time.Time
|
||||
|
||||
stopSign := make(chan os.Signal, 1)
|
||||
signal.Notify(stopSign, os.Interrupt, sigTerm)
|
||||
@ -97,8 +98,8 @@ func monitorMain(options serveOptions) {
|
||||
for {
|
||||
maybeReportPanics()
|
||||
|
||||
if t := time.Since(restarts[0]); t < loopThreshold {
|
||||
l.Warnf("%d restarts in %v; not retrying further", countRestarts, t)
|
||||
if t := time.Since(restarts[0]); t < restartLoopThreshold {
|
||||
l.Warnf("%d restarts in %v; not retrying further", restartCounts, t)
|
||||
os.Exit(svcutil.ExitError.AsInt())
|
||||
}
|
||||
|
||||
@ -193,7 +194,7 @@ func monitorMain(options serveOptions) {
|
||||
}
|
||||
|
||||
l.Infoln("Syncthing exited:", err)
|
||||
time.Sleep(1 * time.Second)
|
||||
time.Sleep(restartPause)
|
||||
|
||||
if first {
|
||||
// Let the next child process know that this is not the first time
|
||||
|
@ -7,7 +7,9 @@ After=network.target
|
||||
User=%i
|
||||
ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
RestartSec=1
|
||||
StartLimitIntervalSec=60
|
||||
StartLimitBurst=4
|
||||
SuccessExitStatus=3 4
|
||||
RestartForceExitStatus=3 4
|
||||
|
||||
|
@ -5,7 +5,9 @@ Documentation=man:syncthing(1)
|
||||
[Service]
|
||||
ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
RestartSec=1
|
||||
StartLimitIntervalSec=60
|
||||
StartLimitBurst=4
|
||||
SuccessExitStatus=3 4
|
||||
RestartForceExitStatus=3 4
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user