123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package main
- import (
- "eta_gn/eta_chart_lib/controllers"
- "eta_gn/eta_chart_lib/models"
- _ "eta_gn/eta_chart_lib/routers"
- "eta_gn/eta_chart_lib/services/alarm_msg"
- "eta_gn/eta_chart_lib/utils"
- "fmt"
- "runtime"
- "time"
- "github.com/beego/beego/v2/adapter/logs"
- beego "github.com/beego/beego/v2/server/web"
- "github.com/beego/beego/v2/server/web/context"
- )
- func main() {
- if beego.BConfig.RunMode == "dev" {
- beego.BConfig.WebConfig.DirectoryIndex = true
- beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
- }
- models.AfterInitTable()
- beego.ErrorController(&controllers.ErrorController{})
- beego.BConfig.RecoverFunc = Recover
- beego.Run()
- }
- func Recover(ctx *context.Context, conf *beego.Config) {
- if err := recover(); err != nil {
- if err == beego.ErrAbort {
- return
- }
- if !beego.BConfig.RecoverPanic {
- panic(err)
- }
- stack := ""
- msg := fmt.Sprintf("The request url is %v", ctx.Input.URL())
- stack += msg + "</br>"
- logs.Critical(msg)
- msg = fmt.Sprintf("The request data is %v", string(ctx.Input.RequestBody))
- stack += msg + "</br>"
- logs.Critical(msg)
- msg = fmt.Sprintf("Handler crashed with error %v", err)
- stack += msg + "</br>"
- logs.Critical(msg)
- for i := 1; ; i++ {
- _, file, line, ok := runtime.Caller(i)
- if !ok {
- break
- }
- logs.Critical(fmt.Sprintf("%s:%d", file, line))
- stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d</br>", file, line))
- }
- go alarm_msg.SendAlarmMsg(utils.APPNAME+"崩了"+time.Now().Format("2006-01-02 15:04:05")+"<br/>"+stack, 3)
- }
- return
- }
|