淇敼锛?. 鏂板浜嗛攣鏈哄埗浠ラ槻姝㈠苟鍙戣闂啿绐侊紱2. 淇敼浜嗕竴浜涘彉閲忓悕浠ユ彁楂樹唬鐮佸彲璇绘€э紱 3. 淇浜嗕竴涓彲鑳藉鑷寸紦鍐插尯婧㈠嚭鐨?bug锛屽皢缂撳啿鍖哄ぇ灏忚缃负 4096锛?. 瀵逛唬鐮佽繘琛屼簡涓€浜涘叾浠栫殑灏忔敼杩涘拰浼樺寲銆?

git-svn-id: svn://47.119.165.148/zhub@121 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
lxy
2021-05-03 14:35:44 +00:00
parent ee885e198a
commit b38fdfa058
12 changed files with 356 additions and 29 deletions

48
monitor/monitor.go Normal file
View File

@@ -0,0 +1,48 @@
package monitor
import (
"encoding/json"
"net/http"
"os"
"path"
"zhub/zsub"
)
func StartHttp() {
dir, _ := os.Getwd()
webDir := path.Join(dir, "/public")
http.Handle("/", http.FileServer(http.Dir(webDir)))
http.HandleFunc("/info", info)
http.HandleFunc("/cleanup", cleanup)
http.HandleFunc("/retimer", retimer)
http.ListenAndServe(":1217", nil)
}
func retimer(w http.ResponseWriter, r *http.Request) {
zsub.ZSubx().ReloadTimer()
renderJson(w, "+reload timer ok")
}
func cleanup(w http.ResponseWriter, r *http.Request) {
zsub.ZSubx().Clearup()
renderJson(w, "+OK")
}
func info(w http.ResponseWriter, r *http.Request) {
topics := zsub.Info()
renderJson(w, topics)
}
func renderJson(w http.ResponseWriter, d interface{}) {
var bytes []byte
if str, ok := d.(string); ok {
bytes = []byte(str)
} else {
bytes, _ = json.Marshal(d)
w.Header().Set("content-type", "application/json; charset=utf-8;")
}
w.Write(bytes)
}