houston server config 오버라이드

This commit is contained in:
2024-09-27 17:34:29 +09:00
parent e9370513c2
commit a60dee1645
2 changed files with 18 additions and 6 deletions

View File

@ -32,7 +32,7 @@ type houstonHandler struct {
maingateApiToken string
}
func NewHoustonHandler() HoustonServerWithHandler {
func NewHoustonHandler(apiToken string) HoustonServerWithHandler {
var tmp *houstonHandler
methods := make(map[string]reflect.Method)
@ -44,7 +44,7 @@ func NewHoustonHandler() HoustonServerWithHandler {
return &houstonHandler{
HoustonServer: NewServer(),
methods: methods,
maingateApiToken: loadServerConfig().MaingateApiToken,
maingateApiToken: apiToken,
}
}

View File

@ -5,6 +5,7 @@ import (
"net"
"repositories.action2quare.com/ayo/gocommon"
"repositories.action2quare.com/ayo/gocommon/flagx"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/houston/shared"
"repositories.action2quare.com/ayo/houston/shared/protos"
@ -20,9 +21,8 @@ type HoustonServer interface {
}
type serverConfig struct {
GrpcPort int `json:"grpc_port"`
StorageRoot string `json:"storage_path"`
MaingateApiToken string `json:"maingate_api_token"`
GrpcPort int `json:"grpc_port"`
StorageRoot string `json:"storage_path"`
}
type DeployRequest struct {
@ -109,11 +109,14 @@ type Operation interface {
}
type outerconfig struct {
Houston *struct {
Houston struct {
Server serverConfig `json:"server"`
} `json:"houston"`
}
var storagePath = flagx.String("hs_storage", "", "")
var grpcPort = flagx.Int("hs_grpc_port", 0, "")
func loadServerConfig() serverConfig {
var oc outerconfig
err := gocommon.LoadConfig[outerconfig](&oc)
@ -124,6 +127,15 @@ func loadServerConfig() serverConfig {
}
}
if len(*storagePath) > 0 {
// override
oc.Houston.Server.StorageRoot = *storagePath
}
if *grpcPort != 0 {
oc.Houston.Server.GrpcPort = *grpcPort
}
return oc.Houston.Server
}