1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-10 03:30:20 +00:00

add listconf fix #351

This commit is contained in:
astaxie
2013-12-15 21:22:50 +08:00
parent aea3c68c98
commit f26c19052d
3 changed files with 151 additions and 42 deletions

View File

@ -1,10 +1,8 @@
package toolbox
import (
"fmt"
"log"
"math"
"net/http"
"sort"
"strconv"
"strings"
@ -398,28 +396,6 @@ func AddTask(taskname string, t Tasker) {
AdminTaskList[taskname] = t
}
func TaskStatus(rw http.ResponseWriter, req *http.Request) {
for tname, tk := range AdminTaskList {
fmt.Fprintf(rw, "%s:%s:%s", tname, tk.GetStatus(), tk.GetPrev().String())
}
}
//to run a Task by http from the querystring taskname
//url like /task?taskname=sendmail
func RunTask(rw http.ResponseWriter, req *http.Request) {
req.ParseForm()
taskname := req.Form.Get("taskname")
if t, ok := AdminTaskList[taskname]; ok {
err := t.Run()
if err != nil {
fmt.Fprintf(rw, "%v", err)
}
fmt.Fprintf(rw, "%s run success,Now the Status is %s", t.GetStatus())
} else {
fmt.Fprintf(rw, "there's no task which named:%s", taskname)
}
}
//sort map for tasker
type MapSorter struct {
Keys []string