mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 09:20:55 +00:00
modify middleware
This commit is contained in:
parent
1ff0a31d3f
commit
e904d26e08
@ -257,7 +257,11 @@ func InternalServerError(rw http.ResponseWriter, r *http.Request) {
|
||||
t.Execute(rw, data)
|
||||
}
|
||||
|
||||
func registerErrorHander() {
|
||||
func Errorhandler(err string, h http.HandlerFunc) {
|
||||
ErrorMaps[err] = h
|
||||
}
|
||||
|
||||
func RegisterErrorHander() {
|
||||
if _, ok := ErrorMaps["404"]; !ok {
|
||||
ErrorMaps["404"] = NotFound
|
||||
}
|
||||
|
@ -69,52 +69,6 @@ func DumpHeap() {
|
||||
f.Close()
|
||||
}
|
||||
|
||||
//func showSystemStat(interval time.Duration, count int) {
|
||||
|
||||
// usage1 := &syscall.Rusage{}
|
||||
// var lastUtime int64
|
||||
// var lastStime int64
|
||||
|
||||
// counter := 0
|
||||
// for {
|
||||
|
||||
// //http://man7.org/linux/man-pages/man3/vtimes.3.html
|
||||
// syscall.Getrusage(syscall.RUSAGE_SELF, usage1)
|
||||
|
||||
// utime := (usage1.Utime.Sec * 1000000000) + int64(usage1.Utime.Usec)
|
||||
// stime := (usage1.Stime.Sec * 1000000000) + int64(usage1.Stime.Usec)
|
||||
// userCPUUtil := float64(utime-lastUtime) * 100 / float64(interval)
|
||||
// sysCPUUtil := float64(stime-lastStime) * 100 / float64(interval)
|
||||
// memUtil := usage1.Maxrss * 1024
|
||||
|
||||
// lastUtime = utime
|
||||
// lastStime = stime
|
||||
|
||||
// if counter > 0 {
|
||||
// fmt.Printf("cpu: %3.2f%% us %3.2f%% sy, mem:%s \n", userCPUUtil, sysCPUUtil, toH(uint64(memUtil)))
|
||||
// }
|
||||
|
||||
// counter += 1
|
||||
// if count >= 1 && count < counter {
|
||||
// return
|
||||
// }
|
||||
// time.Sleep(interval)
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
//func ShowSystemStat(seconds int) {
|
||||
// go func() {
|
||||
// interval := time.Duration(seconds) * time.Second
|
||||
// showSystemStat(interval, 0)
|
||||
// }()
|
||||
//}
|
||||
|
||||
//func PrintSystemStats() {
|
||||
// interval := time.Duration(1) * time.Second
|
||||
// showSystemStat(interval, 1)
|
||||
//}
|
||||
|
||||
func ShowGCStat() {
|
||||
go func() {
|
||||
var numGC int64
|
||||
|
@ -1,14 +0,0 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/session"
|
||||
)
|
||||
|
||||
var (
|
||||
GlobalSessions *session.Manager
|
||||
)
|
||||
|
||||
func StartSession(provideName, cookieName string, maxlifetime int64, savePath string) {
|
||||
GlobalSessions, _ = session.NewManager(provideName, cookieName, maxlifetime, savePath)
|
||||
go GlobalSessions.GC()
|
||||
}
|
Loading…
Reference in New Issue
Block a user