[优化] ui优化

This commit is contained in:
ryan
2026-03-12 15:43:32 +08:00
parent eb65c38c56
commit ee539d9b67
9 changed files with 79 additions and 66 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"server_url": "http://127.0.0.1:3000",
"agent_token": "123",
"agent_token": "2bae8c0eef58c3d7cf84464d983052ca",
"data_dir": "./data",
"openresty_container_name": "atsflare-openresty",
"openresty_docker_image": "openresty/openresty:alpine",
-3
View File
@@ -113,12 +113,9 @@ func (r *Runner) Run(ctx context.Context) error {
if !r.hasAgentToken() {
continue
}
log.Printf("agent sync tick: node_id=%s", nodeID)
if err = r.SyncService.SyncOnce(ctx); err != nil {
r.recordSyncError(err)
log.Printf("agent sync failed: %v", err)
} else {
log.Printf("agent sync completed")
}
}
}
-17
View File
@@ -54,7 +54,6 @@ func (c *Client) Heartbeat(ctx context.Context, payload protocol.NodePayload) (*
}
func (c *Client) GetActiveConfig(ctx context.Context) (*protocol.ActiveConfigResponse, error) {
log.Printf("http get active config request")
resp := protocol.APIResponse[protocol.ActiveConfigResponse]{}
if err := c.getJSON(ctx, "/api/agent/config-versions/active", &resp); err != nil {
return nil, err
@@ -100,9 +99,6 @@ func (c *Client) postJSON(ctx context.Context, path string, body any, target any
}
func (c *Client) do(req *http.Request, target any) error {
if !isHeartbeatRequest(req) {
log.Printf("http request start: method=%s path=%s", req.Method, req.URL.Path)
}
res, err := c.httpClient.Do(req)
if err != nil {
log.Printf("http request failed: method=%s path=%s error=%v", req.Method, req.URL.Path, err)
@@ -123,24 +119,11 @@ func (c *Client) do(req *http.Request, target any) error {
log.Printf("http api response failed: method=%s path=%s message=%s", req.Method, req.URL.Path, wrapper.Message)
return errors.New(wrapper.Message)
}
if !isHeartbeatRequest(req) {
log.Printf("http request succeeded: method=%s path=%s", req.Method, req.URL.Path)
}
return nil
}
if err = json.NewDecoder(res.Body).Decode(target); err != nil {
log.Printf("http response decode failed: method=%s path=%s error=%v", req.Method, req.URL.Path, err)
return err
}
if !isHeartbeatRequest(req) {
log.Printf("http request succeeded: method=%s path=%s", req.Method, req.URL.Path)
}
return nil
}
func isHeartbeatRequest(req *http.Request) bool {
if req == nil || req.URL == nil {
return false
}
return req.Method == http.MethodPost && req.URL.Path == "/api/agent/nodes/heartbeat"
}
+1 -4
View File
@@ -416,7 +416,7 @@ func (m *Manager) backup() (*backupState, error) {
return nil, err
}
state.Files = files
log.Printf("nginx backup captured: route_exists=%t support_files=%d", state.RouteExisted, len(state.Files))
log.Printf("backup captured: route_exists=%t support_files=%d", state.RouteExisted, len(state.Files))
return state, nil
}
@@ -450,7 +450,6 @@ func (m *Manager) restore(state *backupState) error {
return err
}
}
log.Printf("nginx backup restored")
return nil
}
@@ -458,7 +457,6 @@ func (m *Manager) writeSupportFiles(supportFiles []protocol.SupportFile) error {
if m.CertDir == "" {
return nil
}
log.Printf("writing nginx support files: cert_dir=%s count=%d", m.CertDir, len(supportFiles))
if err := os.RemoveAll(m.CertDir); err != nil && !os.IsNotExist(err) {
return err
}
@@ -474,7 +472,6 @@ func (m *Manager) writeSupportFiles(supportFiles []protocol.SupportFile) error {
return err
}
}
log.Printf("nginx support files written: cert_dir=%s count=%d", m.CertDir, len(supportFiles))
return nil
}
-3
View File
@@ -51,7 +51,6 @@ func (s *Service) sync(ctx context.Context, startup bool) error {
if startup {
mode = "startup"
}
log.Printf("sync started: mode=%s", mode)
snapshot, err := s.stateStore.Load()
if err != nil {
return err
@@ -61,12 +60,10 @@ func (s *Service) sync(ctx context.Context, startup bool) error {
log.Printf("fetch active config failed: mode=%s error=%v", mode, err)
return err
}
log.Printf("active config fetched: mode=%s version=%s checksum=%s support_files=%d", mode, config.Version, config.Checksum, len(config.SupportFiles))
currentChecksum, err := s.nginxManager.CurrentChecksum()
if err != nil {
return err
}
log.Printf("current local checksum loaded: mode=%s checksum=%s", mode, currentChecksum)
if currentChecksum == config.Checksum {
log.Printf("local openresty config already up to date: mode=%s version=%s", mode, config.Version)
if startup {