(w http.ResponseWriter, r *http.Request)
| 177 | } |
| 178 | |
| 179 | func (h *NodeHandler) handleRun(w http.ResponseWriter, r *http.Request) { |
| 180 | var body struct { |
| 181 | Type string `json:"type"` |
| 182 | } |
| 183 | if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.Type == "" { |
| 184 | body.Type = "auto" |
| 185 | } |
| 186 | |
| 187 | cfg, err := h.loadConfig() |
| 188 | if err != nil { |
| 189 | writeNodeJSON(w, http.StatusInternalServerError, map[string]any{"error": "读取配置失败: " + err.Error()}) |
| 190 | return |
| 191 | } |
| 192 | |
| 193 | if h.runner.IsRunning() { |
| 194 | writeNodeJSON(w, http.StatusOK, map[string]any{"ok": false, "running": true, "message": "已有任务正在运行"}) |
| 195 | return |
| 196 | } |
| 197 | |
| 198 | taskType := body.Type |
| 199 | go h.runner.Run(h.ctx, cfg, taskType) |
| 200 | |
| 201 | writeNodeJSON(w, http.StatusOK, map[string]any{"ok": true, "running": true}) |
| 202 | } |
| 203 | |
| 204 | func (h *NodeHandler) handleStatus(w http.ResponseWriter, r *http.Request) { |
| 205 | status := NodeStatus{ |
nothing calls this directly
no test coverage detected