From 95187d7e1e7488d4b55ac1e9fb275e9de668cac6 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Tue, 22 Aug 2023 09:48:35 -0700 Subject: [PATCH] build release mode --- scripts/build_darwin.sh | 1 + server/routes.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/scripts/build_darwin.sh b/scripts/build_darwin.sh index 3144349b..d7143615 100755 --- a/scripts/build_darwin.sh +++ b/scripts/build_darwin.sh @@ -3,6 +3,7 @@ mkdir -p dist GO_LDFLAGS="-X github.com/jmorganca/ollama/version.Version=$VERSION" +GO_LDFLAGS="$GO_LDFLAGS -X github.com/jmorganca/ollama/server.mode=release" # build universal binary CGO_ENABLED=1 GOARCH=arm64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-arm64 diff --git a/server/routes.go b/server/routes.go index 880eba8a..dbe0a6ad 100644 --- a/server/routes.go +++ b/server/routes.go @@ -25,6 +25,20 @@ import ( "github.com/jmorganca/ollama/vector" ) +var mode string = gin.DebugMode + +func init() { + switch mode { + case gin.DebugMode: + case gin.ReleaseMode: + case gin.TestMode: + default: + mode = gin.DebugMode + } + + gin.SetMode(mode) +} + var loaded struct { mu sync.Mutex