MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / handleRun

Method handleRun

internal/ipsentinel/nodehandler.go:179–202  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

177}
178
179func (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
204func (h *NodeHandler) handleStatus(w http.ResponseWriter, r *http.Request) {
205 status := NodeStatus{

Callers

nothing calls this directly

Calls 5

loadConfigMethod · 0.95
writeNodeJSONFunction · 0.85
IsRunningMethod · 0.80
ErrorMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected