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

View File

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