Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0687195

Browse files
committed
logpolicy: put Synology logs buffer in /tmp
Ongoing log writing keeps the spinning disks from hibernating. Fixes tailscale#3551 Tested on DSM6 and DSM7. Signed-off-by: Denton Gentry <[email protected]>
1 parent fbc079d commit 0687195

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

logpolicy/logpolicy.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import (
4949
"tailscale.com/util/racebuild"
5050
"tailscale.com/util/winutil"
5151
"tailscale.com/version"
52+
"tailscale.com/version/distro"
5253
)
5354

5455
var getLogTargetOnce struct {
@@ -530,9 +531,25 @@ func New(collection string) *Policy {
530531
c.HTTPC = &http.Client{Transport: NewLogtailTransport(u.Host)}
531532
}
532533

533-
filchBuf, filchErr := filch.New(filepath.Join(dir, cmdName), filch.Options{
534+
filchOptions := filch.Options{
534535
ReplaceStderr: redirectStderrToLogPanics(),
535-
})
536+
}
537+
filchPrefix := filepath.Join(dir, cmdName)
538+
539+
// Synology disks cannot hibernate if we're writing logs to them all the time.
540+
// https://github.com/tailscale/tailscale/issues/3551
541+
if runtime.GOOS == "linux" && distro.Get() == distro.Synology {
542+
synologyTmpfsLogs := "/tmp/tailscale-logs"
543+
if err := os.MkdirAll(synologyTmpfsLogs, 0755); err == nil {
544+
filchPrefix = filepath.Join(synologyTmpfsLogs, cmdName)
545+
filchOptions.MaxFileSize = 1 << 20
546+
} else {
547+
// not a fatal error, we can leave the log files on the spinning disk
548+
log.Printf("Unable to create /tmp directory for log storage: %v\n", err)
549+
}
550+
}
551+
552+
filchBuf, filchErr := filch.New(filchPrefix, filchOptions)
536553
if filchBuf != nil {
537554
c.Buffer = filchBuf
538555
if filchBuf.OrigStderr != nil {

0 commit comments

Comments
 (0)