diff --git a/cmd/backend/main.go b/cmd/backend/main.go index defa814..38de08d 100644 --- a/cmd/backend/main.go +++ b/cmd/backend/main.go @@ -53,9 +53,14 @@ func ReverseProxy() gin.HandlerFunc { } func SetUpAsynqMon(app *bootstrap.Application) { + readonly := false + if app.Env.Env == bootstrap.DevelopmentEnv { + readonly = true + } h := asynqmon.New(asynqmon.Options{ RootPath: "/monitoring", // RootPath specifies the root for asynqmon app RedisConnOpt: asynq.RedisClientOpt{Addr: app.Cache.Options().Addr}, + ReadOnly: readonly, }) // Use Gin's Group function to create a route group with the specified prefix diff --git a/pkg/bootstrap/env.go b/pkg/bootstrap/env.go index 8637fd4..1447c3b 100644 --- a/pkg/bootstrap/env.go +++ b/pkg/bootstrap/env.go @@ -6,6 +6,14 @@ import ( "github.com/caarlos0/env/v9" ) +type envType string + +var ( + DevelopmentEnv envType = "development" + ProductionEnv envType = "production" + StageEnv envType = "stage" +) + type Env struct { DB DBEnv `envPrefix:"DB_"` Redis RedisEnv `envPrefix:"REDIS_"` @@ -13,6 +21,7 @@ type Env struct { JWT JWTEnv `envPrefix:"JWT_"` Line LineEnv `envPrefix:"LINE_"` Domain string `env:"DOMAIN"` + Env envType `env:"ENV" envDefault:"development"` } func NewEnv() *Env {