Example #1
0
func recoverAction() {
	if err := recover(); err != nil {
		pc, _, line, _ := runtime.Caller(4)
		actionName := runtime.FuncForPC(pc).Name()
		common.LogInfo(actionName + " end")
		common.LogError(fmt.Sprintf("actionName:%s line:%d, err:%v ", actionName, line, err))
	}
}
Example #2
0
func main() {
	defer recoverapp()

	mux := http.NewServeMux()
	mux.HandleFunc("/", controller.HandlerCore)
	s := &http.Server{
		Addr:           fmt.Sprintf(":%d", controller.Configtools.HttpPort),
		Handler:        mux,
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
	common.LogInfo("web start", controller.Configtools.HttpPort)
	common.LogError(s.ListenAndServe())
}
Example #3
0
func recoverapp() {
	common.LogInfo("web end")
	if err := recover(); err != nil {
		common.LogError("web err:", err)
	}
}