From a60dee1645fa0d89d6f7ea65481dc3683e81ccd6 Mon Sep 17 00:00:00 2001 From: mountain Date: Fri, 27 Sep 2024 17:34:29 +0900 Subject: [PATCH] =?UTF-8?q?houston=20server=20config=20=EC=98=A4=EB=B2=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/http_handler.go | 4 ++-- server/server.go | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/http_handler.go b/server/http_handler.go index f54354d..a3cc317 100644 --- a/server/http_handler.go +++ b/server/http_handler.go @@ -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, } } diff --git a/server/server.go b/server/server.go index 8dc64de..7809203 100644 --- a/server/server.go +++ b/server/server.go @@ -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 }