Skip to content

fix: Accept CODER_CACHE_DIRECTORY with CACHE_DIRECTORY fallback #2236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Reveal CACHE_DIRECTORY value by updating default
  • Loading branch information
mafredri committed Jun 10, 2022
commit 9e458d0cabe51622c1b1c87f96e75f33eb2c1638
12 changes: 6 additions & 6 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ import (

// nolint:gocyclo
func server() *cobra.Command {
defaultCacheDir := filepath.Join(os.TempDir(), "coder-cache")
if dir := os.Getenv("CACHE_DIRECTORY"); dir != "" {
// For compatibility with systemd.
defaultCacheDir = dir
}

var (
accessURL string
address string
Expand All @@ -68,7 +74,6 @@ func server() *cobra.Command {
promAddress string
pprofEnabled bool
pprofAddress string
defaultCacheDir = filepath.Join(os.TempDir(), "coder-cache")
cacheDir string
dev bool
devUserEmail string
Expand Down Expand Up @@ -100,11 +105,6 @@ func server() *cobra.Command {
Use: "server",
Short: "Start a Coder server",
RunE: func(cmd *cobra.Command, args []string) error {
if cacheDir == defaultCacheDir && os.Getenv("CACHE_DIRECTORY") != "" {
// For compatibility with systemd.
cacheDir = os.Getenv("CACHE_DIRECTORY")
}

logger := slog.Make(sloghuman.Sink(os.Stderr))
buildModeDev := semver.Prerelease(buildinfo.Version()) == "-devel"
if verbose || buildModeDev {
Expand Down