modify middleware
Showing
3 changed files
with
5 additions
and
61 deletions
| ... | @@ -257,7 +257,11 @@ func InternalServerError(rw http.ResponseWriter, r *http.Request) { | ... | @@ -257,7 +257,11 @@ func InternalServerError(rw http.ResponseWriter, r *http.Request) { |
| 257 | t.Execute(rw, data) | 257 | t.Execute(rw, data) |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | func registerErrorHander() { | 260 | func Errorhandler(err string, h http.HandlerFunc) { |
| 261 | ErrorMaps[err] = h | ||
| 262 | } | ||
| 263 | |||
| 264 | func RegisterErrorHander() { | ||
| 261 | if _, ok := ErrorMaps["404"]; !ok { | 265 | if _, ok := ErrorMaps["404"]; !ok { |
| 262 | ErrorMaps["404"] = NotFound | 266 | ErrorMaps["404"] = NotFound |
| 263 | } | 267 | } | ... | ... |
| ... | @@ -69,52 +69,6 @@ func DumpHeap() { | ... | @@ -69,52 +69,6 @@ func DumpHeap() { |
| 69 | f.Close() | 69 | f.Close() |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | //func showSystemStat(interval time.Duration, count int) { | ||
| 73 | |||
| 74 | // usage1 := &syscall.Rusage{} | ||
| 75 | // var lastUtime int64 | ||
| 76 | // var lastStime int64 | ||
| 77 | |||
| 78 | // counter := 0 | ||
| 79 | // for { | ||
| 80 | |||
| 81 | // //http://man7.org/linux/man-pages/man3/vtimes.3.html | ||
| 82 | // syscall.Getrusage(syscall.RUSAGE_SELF, usage1) | ||
| 83 | |||
| 84 | // utime := (usage1.Utime.Sec * 1000000000) + int64(usage1.Utime.Usec) | ||
| 85 | // stime := (usage1.Stime.Sec * 1000000000) + int64(usage1.Stime.Usec) | ||
| 86 | // userCPUUtil := float64(utime-lastUtime) * 100 / float64(interval) | ||
| 87 | // sysCPUUtil := float64(stime-lastStime) * 100 / float64(interval) | ||
| 88 | // memUtil := usage1.Maxrss * 1024 | ||
| 89 | |||
| 90 | // lastUtime = utime | ||
| 91 | // lastStime = stime | ||
| 92 | |||
| 93 | // if counter > 0 { | ||
| 94 | // fmt.Printf("cpu: %3.2f%% us %3.2f%% sy, mem:%s \n", userCPUUtil, sysCPUUtil, toH(uint64(memUtil))) | ||
| 95 | // } | ||
| 96 | |||
| 97 | // counter += 1 | ||
| 98 | // if count >= 1 && count < counter { | ||
| 99 | // return | ||
| 100 | // } | ||
| 101 | // time.Sleep(interval) | ||
| 102 | // } | ||
| 103 | |||
| 104 | //} | ||
| 105 | |||
| 106 | //func ShowSystemStat(seconds int) { | ||
| 107 | // go func() { | ||
| 108 | // interval := time.Duration(seconds) * time.Second | ||
| 109 | // showSystemStat(interval, 0) | ||
| 110 | // }() | ||
| 111 | //} | ||
| 112 | |||
| 113 | //func PrintSystemStats() { | ||
| 114 | // interval := time.Duration(1) * time.Second | ||
| 115 | // showSystemStat(interval, 1) | ||
| 116 | //} | ||
| 117 | |||
| 118 | func ShowGCStat() { | 72 | func ShowGCStat() { |
| 119 | go func() { | 73 | go func() { |
| 120 | var numGC int64 | 74 | var numGC int64 | ... | ... |
middleware/session.go
deleted
100644 → 0
| 1 | package middleware | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "github.com/astaxie/beego/session" | ||
| 5 | ) | ||
| 6 | |||
| 7 | var ( | ||
| 8 | GlobalSessions *session.Manager | ||
| 9 | ) | ||
| 10 | |||
| 11 | func StartSession(provideName, cookieName string, maxlifetime int64, savePath string) { | ||
| 12 | GlobalSessions, _ = session.NewManager(provideName, cookieName, maxlifetime, savePath) | ||
| 13 | go GlobalSessions.GC() | ||
| 14 | } |
-
Please register or sign in to post a comment