update config

This commit is contained in:
ivamp 2024-06-16 14:07:26 +08:00
parent 3422f450f1
commit f305bc6ce6
5 changed files with 24 additions and 18 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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"

View File

@ -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())
}

View File

@ -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(