1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-11 09:20:39 +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,5 @@
package toolbox
import (
"fmt"
"net/http"
)
//type DatabaseCheck struct {
//}
@ -28,16 +23,6 @@ func AddHealthCheck(name string, hc HealthChecker) {
AdminCheckList[name] = hc
}
func Healthcheck(rw http.ResponseWriter, req *http.Request) {
for name, h := range AdminCheckList {
if err := h.Check(); err != nil {
fmt.Fprintf(rw, "%s : ok\n", name)
} else {
fmt.Fprintf(rw, "%s : %s\n", name, err.Error())
}
}
}
func init() {
AdminCheckList = make(map[string]HealthChecker)
}

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