StopProcess 요청 추가

This commit is contained in:
2023-05-22 15:40:01 +09:00
parent ca389dfb5c
commit 4724e7ac31
3 changed files with 37 additions and 11 deletions

View File

@ -6,6 +6,7 @@ import (
"net/http" "net/http"
"os" "os"
"path" "path"
"strconv"
"time" "time"
"repositories.action2quare.com/ayo/go-ayo/logger" "repositories.action2quare.com/ayo/go-ayo/logger"
@ -180,13 +181,38 @@ func (h *houstonHandler) StartProcess(w http.ResponseWriter, r *http.Request) {
Version: version, Version: version,
Args: args, // 실행 파일 포함 e.g. "biglocal.exe -port=8090 -dev", Args: args, // 실행 파일 포함 e.g. "biglocal.exe -port=8090 -dev",
}, targets)) }, targets))
}
// svr.Operation().Start(server.MakeStartRequest(
// common.StartRequest{ func (h *houstonHandler) StopProcess(w http.ResponseWriter, r *http.Request) {
// Name: "warehouse", // <form action="/houston" method="post" enctype="multipart/form-data">
// Version: "latest", // <input type="text" name="name">
// Args: "biglocal.exe -port=8090 -dev", // <input type="text" name="version">
// }, // <input type="text" name="args">
// []string{"mountain"}, // <input type="text" name="targets">
// )) // <input type="submit" value="업로드">
// </form>
name := r.FormValue("name")
if len(name) == 0 {
w.WriteHeader(http.StatusBadRequest)
return
}
version := r.FormValue("version") // option
pidstr := r.FormValue("pid") // option
traws := r.FormValue("targets")
var targets []string
if err := json.Unmarshal([]byte(traws), &targets); err != nil {
logger.Error(err)
w.WriteHeader(http.StatusBadRequest)
return
}
pid, _ := strconv.Atoi(pidstr)
h.Operation().StopProcess(MakeStopProcessRequest(shared.StopProcessRequest{
Name: name,
Version: version,
Pid: int32(pid),
}, targets))
} }

View File

@ -41,7 +41,7 @@ func NewHoustonHandler() HoustonServerWithHandler {
} }
func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error { func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error {
serveMux.Handle(path.Join(prefix, "houston"), h) serveMux.Handle("/"+path.Join(prefix, "houston"), h)
return nil return nil
} }

View File

@ -58,7 +58,7 @@ type StopProcessRequest struct {
hostnames []string hostnames []string
} }
func MakeStopRequest(req shared.StopProcessRequest, targets []string) StopProcessRequest { func MakeStopProcessRequest(req shared.StopProcessRequest, targets []string) StopProcessRequest {
return StopProcessRequest{ return StopProcessRequest{
StopProcessRequest: req, StopProcessRequest: req,
hostnames: targets, hostnames: targets,