From b1baf4503d6f28680e91c7451868545a16926ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A9=BA=E8=A7=81?= Date: Wed, 4 Feb 2015 18:07:31 +0800 Subject: [PATCH] beego task list update for task spec list and task run url error --- admin.go | 6 ++++-- adminui.go | 2 +- toolbox/task.go | 10 +++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/admin.go b/admin.go index d918b595..90142c55 100644 --- a/admin.go +++ b/admin.go @@ -397,7 +397,7 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) { if err != nil { data["Message"] = []string{"error", fmt.Sprintf("%s", err)} } - data["Message"] = []string{"success", fmt.Sprintf("%s run success,Now the Status is %s", taskname, t.GetStatus())} + data["Message"] = []string{"success", fmt.Sprintf("%s run success,Now the Status is
%s", taskname, t.GetStatus())} } else { data["Message"] = []string{"warning", fmt.Sprintf("there's no task which named: %s", taskname)} } @@ -410,12 +410,14 @@ func taskStatus(rw http.ResponseWriter, req *http.Request) { var fields = []string{ fmt.Sprintf("Task Name"), fmt.Sprintf("Task Spec"), - fmt.Sprintf("Task Function"), + fmt.Sprintf("Task Status"), + fmt.Sprintf("Last Time"), fmt.Sprintf(""), } for tname, tk := range toolbox.AdminTaskList { result = []string{ fmt.Sprintf("%s", tname), + fmt.Sprintf("%s", tk.GetSpec()), fmt.Sprintf("%s", tk.GetStatus()), fmt.Sprintf("%s", tk.GetPrev().String()), } diff --git a/adminui.go b/adminui.go index 77b5cd33..7bb32b34 100644 --- a/adminui.go +++ b/adminui.go @@ -186,7 +186,7 @@ bg-warning {{end}} - Run + Run {{end}} diff --git a/toolbox/task.go b/toolbox/task.go index b50c54fb..23e2fb5e 100644 --- a/toolbox/task.go +++ b/toolbox/task.go @@ -84,6 +84,7 @@ type TaskFunc func() error // task interface type Tasker interface { + GetSpec() string GetStatus() string Run() error SetNext(time.Time) @@ -102,6 +103,7 @@ type taskerr struct { type Task struct { Taskname string Spec *Schedule + SpecStr string DoFunc TaskFunc Prev time.Time Next time.Time @@ -116,16 +118,22 @@ func NewTask(tname string, spec string, f TaskFunc) *Task { Taskname: tname, DoFunc: f, ErrLimit: 100, + SpecStr: spec, } task.SetCron(spec) return task } +//get spec string +func (s *Task) GetSpec() string { + return s.SpecStr +} + // get current task status func (tk *Task) GetStatus() string { var str string for _, v := range tk.Errlist { - str += v.t.String() + ":" + v.errinfo + "\n" + str += v.t.String() + ":" + v.errinfo + "
" } return str }