Merge pull request #1694 from ibuildthecloud/inittwice

Allow InitLogging to be called twice
pull/1752/head
Erik Wilson 2020-05-04 20:22:04 -07:00 committed by GitHub
commit df1725cb06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import (
"io" "io"
"os" "os"
"strconv" "strconv"
"sync"
"time" "time"
"github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/reexec"
@ -43,19 +44,26 @@ var (
Usage: "(logging) Log to standard error as well as file (if set)", Usage: "(logging) Log to standard error as well as file (if set)",
Destination: &LogConfig.AlsoLogToStderr, Destination: &LogConfig.AlsoLogToStderr,
} }
logSetupOnce sync.Once
) )
func InitLogging() error { func InitLogging() error {
if LogConfig.LogFile != "" && os.Getenv("_K3S_LOG_REEXEC_") == "" { var rErr error
return runWithLogging() logSetupOnce.Do(func() {
} if LogConfig.LogFile != "" && os.Getenv("_K3S_LOG_REEXEC_") == "" {
rErr = runWithLogging()
return
}
if err := checkUnixTimestamp(); err != nil { if err := checkUnixTimestamp(); err != nil {
return err rErr = err
} return
}
setupLogging() setupLogging()
return nil })
return rErr
} }
func checkUnixTimestamp() error { func checkUnixTimestamp() error {