From d920537716d0ed5c92ffcdf421be7f7b576806a3 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 31 May 2024 17:05:30 -0400 Subject: [PATCH] Switched to release mode + small json speedup --- Dockerfile | 2 +- main.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b0da5b6..7d64b29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.22@sha256:0b55ab82ac2a54a6f8f85ec8b943b9e470c39e32c109b766bbc1b801 WORKDIR /src COPY . . RUN go mod download -RUN CGO_ENABLED=0 GOOS=linux go build -o ./abacus +RUN CGO_ENABLED=0 GOOS=linux go build -o ./abacus -tags=jsoniter # Run stage FROM alpine:latest diff --git a/main.go b/main.go index 697e020..41cc614 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,14 @@ package main import ( "fmt" - "github.com/redis/go-redis/v9" "net/http" "os" "strconv" + "strings" "time" + "github.com/redis/go-redis/v9" + "github.com/jasonlovesdoggo/abacus/middleware" "github.com/gin-contrib/cors" @@ -33,6 +35,13 @@ var ( func init() { // Connect to Redis utils.LoadEnv() + + if strings.ToLower(os.Getenv("DEBUG")) == "true" { + gin.SetMode(gin.DebugMode) + } else { + gin.SetMode(gin.ReleaseMode) + } + ADDR := os.Getenv("REDIS_HOST") + ":" + os.Getenv("REDIS_PORT") fmt.Println("Listening to redis on: " + ADDR) DbNum, _ := strconv.Atoi(os.Getenv("REDIS_DB"))