Compare commits

..

1 Commits

Author SHA1 Message Date
b01f32bc24 kd live는 go 1.18 2023-06-21 18:27:35 +09:00
3 changed files with 8 additions and 30 deletions

View File

@ -20,15 +20,9 @@ import (
현재 접속 중인 Agent 목록을 보여줍니다.
- http method : GET
*/
const (
sub_folder_name_deploys = string("_deploys")
sub_folder_name_downloads = string("_downloads")
)
func (h *houstonHandler) GetAgents(w http.ResponseWriter, r *http.Request) {
enc := json.NewEncoder(w)
allHosts := h.Operation().Hosts()
enc.Encode(allHosts)
enc.Encode(h.Operation().Hosts())
}
func (h *houstonHandler) GetDeploySources(w http.ResponseWriter, r *http.Request) {
@ -90,7 +84,7 @@ func (h *houstonHandler) UploadDeploySource(w http.ResponseWriter, r *http.Reque
var filename string
if version == "config" {
filename = path.Join(h.deployPath, name, version, "config"+ext)
filename = path.Join(h.deployPath, name, version, "config.json")
} else {
// deploys 폴더는 파일시스템 서비스이므로 다운로드 가능
filename = path.Join(h.deployPath, name, version, name+ext)
@ -186,14 +180,14 @@ func (h *houstonHandler) Deploy(w http.ResponseWriter, r *http.Request) {
configPath := ""
if _, err := os.Stat(path.Join(h.deployPath, name, "config", "config.json")); err == nil || errors.Is(err, fs.ErrExist) {
configPath = path.Join(sub_folder_name_deploys, name, "config", "config.json")
configPath = path.Join("deploys", name, "config", "config.json")
}
h.Operation().Deploy(MakeDeployRequest(
shared.DeployRequest{
Name: name,
Version: version,
Url: path.Join(sub_folder_name_deploys, name, version, latestFilename),
Url: path.Join("deploys", name, version, latestFilename),
Config: configPath,
},
targets,
@ -363,7 +357,7 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request)
var out []string
for _, lf := range logfiles {
out = append(out, path.Join(sub_folder_name_downloads, name, version, lf.Name()))
out = append(out, path.Join("downloads", name, version, lf.Name()))
}
enc := json.NewEncoder(w)

View File

@ -45,10 +45,9 @@ func NewHoustonHandler() HoustonServerWithHandler {
}
func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error {
config := loadServerConfig()
storagePath := config.StorageRoot
h.deployPath = path.Join(storagePath, sub_folder_name_deploys)
h.downloadPath = path.Join(storagePath, sub_folder_name_downloads)
storagePath := loadServerConfig().StorageRoot
h.deployPath = path.Join(storagePath, "deploys")
h.downloadPath = path.Join(storagePath, "downloads")
if err := os.MkdirAll(h.deployPath, 0775); err != nil {
return err

View File

@ -5,10 +5,8 @@ import (
"fmt"
"net"
"os"
"time"
"repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/houston/client"
"repositories.action2quare.com/ayo/houston/shared"
"repositories.action2quare.com/ayo/houston/shared/protos"
@ -25,7 +23,6 @@ type HoustonServer interface {
type serverConfig struct {
GrpcPort int `json:"grpc_port"`
StorageRoot string `json:"storage_path"`
RunAsClient bool `json:"run_as_client"`
}
type DeployRequest struct {
@ -176,18 +173,6 @@ func (hs *houstonServer) Start() error {
return err
}
if loadServerConfig().RunAsClient {
go func() {
time.Sleep(time.Second)
hc, err := client.NewClient()
if err != nil {
logger.Fatal(err)
return
}
hc.Start()
}()
}
if err := hs.rpcServer.Serve(lis); err != nil {
return err
}