diff --git a/go/ckit/cache/cache.go b/go/ckit/cache/cache.go index ed6c9c6..8c3c8e0 100644 --- a/go/ckit/cache/cache.go +++ b/go/ckit/cache/cache.go @@ -86,16 +86,18 @@ func (c *Cache) startSizeWatcher() { for t := range ticker.C { fi, err := os.Stat(c.Path) if err != nil { - log.Printf("could not stat file at %s, stopping watch thread", c.Path) + log.Printf("[cache] could not stat file at %s", c.Path) break } if fi.Size() > c.MaxFileSize { c.Lock() - log.Printf("switching cache at %s to read-only mode at %v", c.Path, t) + log.Printf("[cache] switching %s to read-only mode at %v", c.Path, t.Format(time.RFC3339)) c.readOnly = true c.Unlock() + break } } + log.Printf("[cache] stopping file watcher thread") }() } diff --git a/go/ckit/cmd/labed/main.go b/go/ckit/cmd/labed/main.go index 5e079eb..59a33f7 100644 --- a/go/ckit/cmd/labed/main.go +++ b/go/ckit/cmd/labed/main.go @@ -40,6 +40,7 @@ var ( enableGzip = flag.Bool("z", false, "enable gzip compression") enableCache = flag.Bool("c", false, "enable caching of expensive responses") cacheTriggerDuration = flag.Duration("t", 250*time.Millisecond, "cache trigger duration") + cacheMaxFileSize = flag.Int64("cx", 1<<36, "maximum filesize cache in bytes") showVersion = flag.Bool("version", false, "show version") accessLogFile = flag.String("a", "", "path to access log file, do not write access log if empty") logFile = flag.String("logfile", "", "application log file (stderr if empty)") @@ -200,6 +201,7 @@ func main() { log.Fatal(err) } defer c.Close() + c.MaxFileSize = *cacheMaxFileSize srv.Cache = c srv.CacheTriggerDuration = *cacheTriggerDuration }