MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / Execute

Method Execute

agent/app/task/task.go:285–321  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

283}
284
285func (t *Task) Execute() error {
286 if err := t.taskRepo.Save(context.Background(), t.Task); err != nil {
287 return err
288 }
289 var err error
290 t.Log(i18n.GetWithName("TaskStart", t.Name))
291 for i := 0; i < len(t.SubTasks); i++ {
292 subTask := t.SubTasks[i]
293 t.Task.CurrentStep = subTask.StepAlias
294 t.updateTask(t.Task)
295 if err = subTask.Execute(); err == nil {
296 if subTask.Rollback != nil {
297 t.Rollbacks = append(t.Rollbacks, subTask.Rollback)
298 }
299 } else {
300 if subTask.IgnoreErr {
301 err = nil
302 continue
303 }
304 t.Task.ErrorMsg = err.Error()
305 t.Task.Status = constant.StatusFailed
306 for _, rollback := range t.Rollbacks {
307 rollback(t)
308 }
309 t.updateTask(t.Task)
310 break
311 }
312 }
313 if t.Task.Status == constant.StatusExecuting {
314 t.Task.Status = constant.StatusSuccess
315 }
316 t.Log("[TASK-END]")
317 t.Task.EndAt = time.Now()
318 t.updateTask(t.Task)
319 _ = t.logFile.Close()
320 return err
321}
322
323func (t *Task) DeleteLogFile() {
324 _ = os.Remove(t.Task.LogFile)

Callers 15

CompressMethod · 0.95
DeCompressMethod · 0.95
SnapshotRecoverMethod · 0.95
googleRequestMethod · 0.45
mainFunction · 0.45
handleRedisBackupFunction · 0.45
handleRedisRecoverFunction · 0.45
handleWebsiteRecoverFunction · 0.45
handleWebsiteBackupFunction · 0.45
BatchInstallSkillMethod · 0.45
UpdateSwapMethod · 0.45
ConvertMethod · 0.45

Calls 5

LogMethod · 0.95
updateTaskMethod · 0.95
SaveMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected