X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/060d38d627bd1e51dd2b3c6e7de9af6aa7d7b6f3..39c17737ac69d7693684fe2f95bef0ec235a28bf:/services/keepstore/config.go diff --git a/services/keepstore/config.go b/services/keepstore/config.go index 19a614a1fa..1f8c7e31a2 100644 --- a/services/keepstore/config.go +++ b/services/keepstore/config.go @@ -13,7 +13,7 @@ import ( "time" "git.curoverse.com/arvados.git/sdk/go/arvados" - log "github.com/Sirupsen/logrus" + "github.com/Sirupsen/logrus" ) type Config struct { @@ -34,15 +34,35 @@ type Config struct { EnableDelete bool TrashLifetime arvados.Duration TrashCheckInterval arvados.Duration + PullWorkers int + TrashWorkers int + EmptyTrashWorkers int + TLSCertificateFile string + TLSKeyFile string Volumes VolumeList blobSigningKey []byte systemAuthToken string debugLogf func(string, ...interface{}) + + ManagementToken string `doc: The secret key that must be provided by monitoring services +wishing to access the health check endpoint (/_health).` } -var theConfig = DefaultConfig() +var ( + theConfig = DefaultConfig() + formatter = map[string]logrus.Formatter{ + "text": &logrus.TextFormatter{ + FullTimestamp: true, + TimestampFormat: rfc3339NanoFixed, + }, + "json": &logrus.JSONFormatter{ + TimestampFormat: rfc3339NanoFixed, + }, + } + log = logrus.StandardLogger() +) const rfc3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00" @@ -64,26 +84,19 @@ func DefaultConfig() *Config { // fields, and before using the config. func (cfg *Config) Start() error { if cfg.Debug { - log.SetLevel(log.DebugLevel) + log.Level = logrus.DebugLevel cfg.debugLogf = log.Printf cfg.debugLogf("debugging enabled") } else { + log.Level = logrus.InfoLevel cfg.debugLogf = func(string, ...interface{}) {} } - switch strings.ToLower(cfg.LogFormat) { - case "text": - log.SetFormatter(&log.TextFormatter{ - FullTimestamp: true, - TimestampFormat: rfc3339NanoFixed, - }) - case "json": - log.SetFormatter(&log.JSONFormatter{ - TimestampFormat: rfc3339NanoFixed, - }) - default: + f := formatter[strings.ToLower(cfg.LogFormat)] + if f == nil { return fmt.Errorf(`unsupported log format %q (try "text" or "json")`, cfg.LogFormat) } + log.Formatter = f if cfg.MaxBuffers < 0 { return fmt.Errorf("MaxBuffers must be greater than zero") @@ -146,9 +159,9 @@ var VolumeTypes = []func() VolumeWithExamples{} type VolumeList []Volume -// UnmarshalJSON, given an array of objects, deserializes each object -// as the volume type indicated by the object's Type field. -func (vols *VolumeList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON -- given an array of objects -- deserializes each +// object as the volume type indicated by the object's Type field. +func (vl *VolumeList) UnmarshalJSON(data []byte) error { typeMap := map[string]func() VolumeWithExamples{} for _, factory := range VolumeTypes { t := factory().Type() @@ -181,7 +194,7 @@ func (vols *VolumeList) UnmarshalJSON(data []byte) error { if err != nil { return err } - *vols = append(*vols, vol) + *vl = append(*vl, vol) } return nil }