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"
"os"
"path"
"strconv"
"time"
"repositories.action2quare.com/ayo/go-ayo/logger"
@ -180,13 +181,38 @@ func (h *houstonHandler) StartProcess(w http.ResponseWriter, r *http.Request) {
Version: version,
Args: args, // 실행 파일 포함 e.g. "biglocal.exe -port=8090 -dev",
}, targets))
// svr.Operation().Start(server.MakeStartRequest(
// common.StartRequest{
// Name: "warehouse",
// Version: "latest",
// Args: "biglocal.exe -port=8090 -dev",
// },
// []string{"mountain"},
// ))
}
func (h *houstonHandler) StopProcess(w http.ResponseWriter, r *http.Request) {
// <form action="/houston" method="post" enctype="multipart/form-data">
// <input type="text" name="name">
// <input type="text" name="version">
// <input type="text" name="args">
// <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 {
serveMux.Handle(path.Join(prefix, "houston"), h)
serveMux.Handle("/"+path.Join(prefix, "houston"), h)
return nil
}

View File

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