about summary refs log tree commit diff stats
path: root/cmd
diff options
context:
space:
mode:
authorAlan Pearce2024-06-29 10:13:44 +0200
committerAlan Pearce2024-06-29 10:13:44 +0200
commit6e092d6456f870df0ae90f400e6848d748a93c4c (patch)
tree7d0a890aa23b137f60860784f840d69f7d62eaf4 /cmd
parent8606328379e7021a2e4bf0d56c0602fa595fa72e (diff)
downloadwebsite-6e092d6456f870df0ae90f400e6848d748a93c4c.tar.lz
website-6e092d6456f870df0ae90f400e6848d748a93c4c.tar.zst
website-6e092d6456f870df0ae90f400e6848d748a93c4c.zip
only create a tempdir in development mode
Diffstat (limited to 'cmd')
-rw-r--r--cmd/server/main.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/cmd/server/main.go b/cmd/server/main.go
index d73e19f..2f1674e 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -25,12 +25,14 @@ func main() {
 	}
 	log.Configure(!runtimeConfig.Development)
 
-	tmpdir, err := os.MkdirTemp("", "website")
-	if err != nil {
-		log.Fatal("could not create temporary directory", "error", err)
+	if runtimeConfig.Development {
+		tmpdir, err := os.MkdirTemp("", "website")
+		if err != nil {
+			log.Fatal("could not create temporary directory", "error", err)
+		}
+		defer os.RemoveAll(tmpdir)
+		runtimeConfig.Root = tmpdir
 	}
-	defer os.RemoveAll(tmpdir)
-	runtimeConfig.Root = tmpdir
 
 	sv, err := server.New(&runtimeConfig)
 	if err != nil {