fix: Update default cache directory (#4175)

Fixes #2534.
This commit is contained in:
Kyle Carberry
2022-09-23 14:26:29 -05:00
committed by GitHub
parent 38e2a28ada
commit f160830226
+6 -1
View File
@@ -785,11 +785,16 @@ func Server(newAPI func(context.Context, *coderd.Options) (*coderd.API, error))
"Serve pprof metrics on the address defined by `pprof-address`.")
cliflag.StringVarP(root.Flags(), &pprofAddress, "pprof-address", "", "CODER_PPROF_ADDRESS", "127.0.0.1:6060",
"The bind address to serve pprof.")
defaultCacheDir := filepath.Join(os.TempDir(), "coder-cache")
defaultCacheDir, err := os.UserCacheDir()
if err != nil {
defaultCacheDir = os.TempDir()
}
if dir := os.Getenv("CACHE_DIRECTORY"); dir != "" {
// For compatibility with systemd.
defaultCacheDir = dir
}
defaultCacheDir = filepath.Join(defaultCacheDir, "coder")
cliflag.StringVarP(root.Flags(), &cacheDir, "cache-dir", "", "CODER_CACHE_DIRECTORY", defaultCacheDir,
"The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with systemd.")
cliflag.BoolVarP(root.Flags(), &inMemoryDatabase, "in-memory", "", "CODER_INMEMORY", false,