config 구조 변경
This commit is contained in:
@ -25,10 +25,6 @@ type serverConfig struct {
|
||||
StoragePath string `json:"storage_path"`
|
||||
}
|
||||
|
||||
type totalConfig struct {
|
||||
Server serverConfig `json:"houston_server"`
|
||||
}
|
||||
|
||||
type DeployRequest struct {
|
||||
shared.DeployRequest
|
||||
hostnames []string
|
||||
@ -111,24 +107,39 @@ type Operation interface {
|
||||
Hosts() map[string]hostSnapshot
|
||||
}
|
||||
|
||||
func loadConfig() serverConfig {
|
||||
var config totalConfig
|
||||
|
||||
config.Server.GrpcPort = 8080
|
||||
func loadServerConfig() serverConfig {
|
||||
configFile, err := os.Open("config.json")
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return config.Server
|
||||
return serverConfig{
|
||||
GrpcPort: 8080,
|
||||
}
|
||||
}
|
||||
defer configFile.Close()
|
||||
|
||||
var config struct {
|
||||
Houston *struct {
|
||||
Server serverConfig `json:"server"`
|
||||
} `json:"houston"`
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(configFile)
|
||||
err = dec.Decode(&config)
|
||||
if err != nil {
|
||||
logger.Error(err)
|
||||
return config.Server
|
||||
return serverConfig{
|
||||
GrpcPort: 8080,
|
||||
}
|
||||
}
|
||||
|
||||
return config.Server
|
||||
if config.Houston == nil {
|
||||
logger.Error(`"houston" object is missing in config.json`)
|
||||
return serverConfig{
|
||||
GrpcPort: 8080,
|
||||
}
|
||||
}
|
||||
|
||||
return config.Houston.Server
|
||||
}
|
||||
|
||||
func NewServer() HoustonServer {
|
||||
@ -144,7 +155,7 @@ func NewServer() HoustonServer {
|
||||
rpcServer: grpcServer,
|
||||
os: os,
|
||||
ms: ms,
|
||||
port: loadConfig().GrpcPort,
|
||||
port: loadServerConfig().GrpcPort,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user