mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
logpolicy: put Synology logs buffer in /tmp
Ongoing log writing keeps the spinning disks from hibernating. Fixes https://github.com/tailscale/tailscale/issues/3551 Tested on DSM6 and DSM7. Signed-off-by: Denton Gentry <dgentry@tailscale.com>
This commit is contained in:
parent
fbc079d82d
commit
0687195bee
@ -49,6 +49,7 @@
|
||||
"tailscale.com/util/racebuild"
|
||||
"tailscale.com/util/winutil"
|
||||
"tailscale.com/version"
|
||||
"tailscale.com/version/distro"
|
||||
)
|
||||
|
||||
var getLogTargetOnce struct {
|
||||
@ -530,9 +531,25 @@ func New(collection string) *Policy {
|
||||
c.HTTPC = &http.Client{Transport: NewLogtailTransport(u.Host)}
|
||||
}
|
||||
|
||||
filchBuf, filchErr := filch.New(filepath.Join(dir, cmdName), filch.Options{
|
||||
filchOptions := filch.Options{
|
||||
ReplaceStderr: redirectStderrToLogPanics(),
|
||||
})
|
||||
}
|
||||
filchPrefix := filepath.Join(dir, cmdName)
|
||||
|
||||
// Synology disks cannot hibernate if we're writing logs to them all the time.
|
||||
// https://github.com/tailscale/tailscale/issues/3551
|
||||
if runtime.GOOS == "linux" && distro.Get() == distro.Synology {
|
||||
synologyTmpfsLogs := "/tmp/tailscale-logs"
|
||||
if err := os.MkdirAll(synologyTmpfsLogs, 0755); err == nil {
|
||||
filchPrefix = filepath.Join(synologyTmpfsLogs, cmdName)
|
||||
filchOptions.MaxFileSize = 1 << 20
|
||||
} else {
|
||||
// not a fatal error, we can leave the log files on the spinning disk
|
||||
log.Printf("Unable to create /tmp directory for log storage: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
filchBuf, filchErr := filch.New(filchPrefix, filchOptions)
|
||||
if filchBuf != nil {
|
||||
c.Buffer = filchBuf
|
||||
if filchBuf.OrigStderr != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user