MCPcopy Create free account
hub / github.com/astercloud/aster / updateTaskStatus

Method updateTaskStatus

pkg/tools/builtin/task_manager.go:420–441  ·  view source on GitHub ↗

updateTaskStatus 更新任务状态

(task *TaskInfo)

Source from the content-addressed store, hash-verified

418
419// updateTaskStatus 更新任务状态
420func (tm *FileTaskManager) updateTaskStatus(task *TaskInfo) {
421 if task.PID <= 0 {
422 return
423 }
424
425 // 检查进程是否还存在
426 proc, err := os.FindProcess(task.PID)
427 if err != nil {
428 return
429 }
430
431 err = proc.Signal(syscall.Signal(0))
432 if err != nil {
433 // 进程不存在,更新状态
434 now := time.Now()
435 task.EndTime = &now
436 task.Duration = now.Sub(task.StartTime)
437 task.Status = "completed"
438 task.LastUpdate = now
439 _ = tm.saveTask(task)
440 }
441}
442
443// waitForProcessExit 等待进程退出
444func (tm *FileTaskManager) waitForProcessExit(task *TaskInfo, timeout int) {

Callers 2

GetTaskMethod · 0.95
ListTasksMethod · 0.95

Calls 1

saveTaskMethod · 0.95

Tested by

no test coverage detected