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:
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user