diff --git a/.env.example b/.env.example index a7a0de8..250b97f 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,17 @@ +HTTP_LISTEN_ADDR=127.0.0.1:8080 +GRPC_LISTEN_ADDR= + DB_DSN= REDIS_ADDR= REDIS_PASS= -LISTEN_ADDR= + JWKS_URL=https://auth.leaflow.cn/realms/Ecosystem/protocol/openid-connect/certs + +S3_ENDPOINT= +S3_ACCESS_KEY= +S3_SECRET_KEY= +S3_BUCKET= +S3_USE_SSL=false + DEBUG=false -HTTP_LISTEN_ADDR=127.0.0.1:8080 \ No newline at end of file diff --git a/internal/app/config/config.go b/internal/app/config/config.go index 1bd0b16..203328e 100644 --- a/internal/app/config/config.go +++ b/internal/app/config/config.go @@ -20,12 +20,9 @@ type defaultConfig struct { Driver string } - GRPC struct { - GrpcListenAddr string - } - - HTTP struct { - ListenAddr string + ListenAddr struct { + GRPC string + HTTP string } JWKS struct { diff --git a/internal/app/config/init.go b/internal/app/config/init.go index b70ded8..a4d7c5a 100644 --- a/internal/app/config/init.go +++ b/internal/app/config/init.go @@ -13,8 +13,8 @@ func InitConfig() { Config.DB.Driver = "postgres" Config.Redis.Addr = GetEnv("REDIS_ADDR") Config.Redis.Pass = GetEnv("REDIS_PASS") - Config.GRPC.GrpcListenAddr = GetEnv("LISTEN_ADDR") - Config.HTTP.ListenAddr = GetEnv("HTTP_LISTEN_ADDR") + Config.ListenAddr.GRPC = GetEnv("GRPC_LISTEN_ADDR") + Config.ListenAddr.HTTP = GetEnv("HTTP_LISTEN_ADDR") Config.JWKS.Url = GetEnv("JWKS_URL") Config.DebugMode.Enable = GetEnv("DEBUG", "false") == "true" diff --git a/internal/cmd/http.go b/internal/cmd/http.go index df32b09..ad70282 100644 --- a/internal/cmd/http.go +++ b/internal/cmd/http.go @@ -28,12 +28,12 @@ var httpCommand = &cobra.Command{ } func StartHttp() { - if config.Config.HTTP.ListenAddr == "" { - config.Config.HTTP.ListenAddr = "0.0.0.0:8080" + if config.Config.ListenAddr.HTTP == "" { + config.Config.ListenAddr.HTTP = "0.0.0.0:8080" } - logger.Logger.Info("Http Server listening at " + config.Config.HTTP.ListenAddr) - err := facades.Router.Run(config.Config.HTTP.ListenAddr) + logger.Logger.Info("Http Server listening at " + config.Config.ListenAddr.HTTP) + err := facades.Router.Run(config.Config.ListenAddr.HTTP) if err != nil { panic("failed to listen: " + err.Error()) } diff --git a/internal/cmd/rpc.go b/internal/cmd/rpc.go index ced2b65..a1d2c5c 100644 --- a/internal/cmd/rpc.go +++ b/internal/cmd/rpc.go @@ -33,15 +33,15 @@ var rpcCommand = &cobra.Command{ } func StartSpiderService() { - if config.Config.GRPC.GrpcListenAddr == "" { - config.Config.GRPC.GrpcListenAddr = "0.0.0.0:8081" + if config.Config.ListenAddr.GRPC == "" { + config.Config.ListenAddr.GRPC = "0.0.0.0:8081" } - lis, err := net.Listen("tcp", config.Config.GRPC.GrpcListenAddr) + lis, err := net.Listen("tcp", config.Config.ListenAddr.GRPC) if err != nil { panic("failed to listen: " + err.Error()) } - logger.Logger.Info("Server listening at " + config.Config.GRPC.GrpcListenAddr) + logger.Logger.Info("Server listening at " + config.Config.ListenAddr.GRPC) var opts = []grpc.ServerOption{ grpc.ChainUnaryInterceptor(