Skip to content

Commit

Permalink
support dog in event
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleLollipop committed Oct 9, 2024
1 parent 134f69d commit 60fa7fc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 13 additions & 0 deletions internal/watchdog/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ func NewWatchDogManager() *Manager {
return &Manager{ManagerMap: make(ManagerMap)}
}

func (w *Manager) GetProgress(uid string) string {

manager, exists := w.ManagerMap[uid]
if !exists || manager == nil {
glog.Info("GetProgress-Event:", uid, "not found or nil")
return ""
}

glog.Info("GetProgress-Event:", uid, manager.progress)
return manager.progress
}

func (w *Manager) NewWatchDog(installOp, appname, uid, token, from, cfgType string, info *models.ApplicationInfo) *InstallationWatchDog {
w.mu.Lock()
defer w.mu.Unlock()
Expand Down Expand Up @@ -119,6 +131,7 @@ func (w *Manager) NewWatchDog(installOp, appname, uid, token, from, cfgType stri
clear: w.DeleteWatchDog,
}
w.ManagerMap[uid] = wd
glog.Info("NewWatchDog-Event:", uid)

return wd
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/apiserver/service/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func getRunningModelList(token string) ([]*models.ModelStatusResponse, error) {
}

jsonStr, _, err := appservice.LlmStatusList(token)
glog.Infof("LlmStatusList:res:%s", jsonStr)
// glog.Infof("LlmStatusList:res:%s", jsonStr)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -186,6 +186,7 @@ func parseAppInfos(h *Handler, res *models.ListResultD, appsMap map[string]appse

// merge app info
info.Progress = h.commonWatchDogManager.GetProgress(info.Name)
info.Progress = h.watchDogManager.GetProgress(info.Name)

appWithStatusList = append(appWithStatusList, info)
}
Expand Down Expand Up @@ -332,7 +333,7 @@ func upgradeByType(info *models.ApplicationInfo, token string) (string, error) {
}

func respJsonWithOriginBody(resp *restful.Response, body string) {
glog.Info("body:", body)
// glog.Info("body:", body)
info := make(map[string]interface{})
err := json.Unmarshal([]byte(body), &info)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions pkg/utils/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/golang/glog"
"io"
"market/internal/constants"
"net"
"net/http"
"os"
"sync"
"time"

"github.com/golang/glog"
)

var (
Expand Down Expand Up @@ -120,7 +121,7 @@ func SendHttpRequest(req *http.Request) (string, error) {
if len(debugBody) > 256 {
debugBody = debugBody[:256]
}
glog.Infof("url:%s, method:%s, resp.StatusCode:%d, body:%s", req.URL, req.Method, resp.StatusCode, debugBody)
// glog.Infof("url:%s, method:%s, resp.StatusCode:%d, body:%s", req.URL, req.Method, resp.StatusCode, debugBody)

return string(body), nil
}
Expand Down Expand Up @@ -153,7 +154,7 @@ func SendHttpRequestByte(req *http.Request) ([]byte, error) {
if len(debugBody) > 256 {
debugBody = debugBody[:256]
}
glog.Infof("url:%s, method:%s, resp.StatusCode:%d, body:%s", req.URL, req.Method, resp.StatusCode, debugBody)
// glog.Infof("url:%s, method:%s, resp.StatusCode:%d, body:%s", req.URL, req.Method, resp.StatusCode, debugBody)

return body, nil
}
Expand Down

0 comments on commit 60fa7fc

Please sign in to comment.