renzheng 9 éve
szülő
commit
54abc5377e

+ 1 - 0
common/src/github.com/go-xweb/xweb/app.go

@@ -593,6 +593,7 @@ func (a *App) run(req *http.Request, w http.ResponseWriter, route Route, args []
 	}
 
 	w.Header().Set("Content-Length", strconv.Itoa(len(content)))
+
 	_, err = w.Write(content)
 	if err != nil {
 		a.Error("Error during write: %v", err)

+ 4 - 3
common/src/qfw/util/mongodb/mongodbutil.go

@@ -3,13 +3,14 @@ package mongodb
 import (
 	"encoding/json"
 	"fmt"
-	mgo "gopkg.in/mgo.v2"
-	. "gopkg.in/mgo.v2/bson"
 	"log"
 	. "qfw/util"
 	"runtime"
 	"strings"
 	"time"
+
+	mgo "gopkg.in/mgo.v2"
+	. "gopkg.in/mgo.v2/bson"
 )
 
 //连接池
@@ -74,7 +75,7 @@ func GetMgoConn() (session *mgo.Session) {
 			}
 			return nil
 		}
-	case <-time.After(time.Second * 2):
+	case <-time.After(time.Second * 5):
 		//超时
 		return nil
 	}

+ 2 - 2
core/src/main.go

@@ -3,7 +3,6 @@ package main
 
 import (
 	"flag"
-	"github.com/go-xweb/xweb"
 	_ "qfw/active"
 	_ "qfw/chat"
 	. "qfw/coreconfig"
@@ -35,6 +34,8 @@ import (
 	_ "qfw/yellowpage"
 	"runtime"
 	"time"
+
+	"github.com/go-xweb/xweb"
 )
 
 //初始化
@@ -75,7 +76,6 @@ func init() {
 	xweb.RootApp().AddTmplVar("Msg", tag.Msg)
 	xweb.RootApp().AddTmplVar("Ad", tag.Ad)
 	xweb.RootApp().AppConfig.CacheTemplates = SysConfig.TemplateCache
-
 	xweb.RootApp().Logger.SetOutputLevel(0) //输出日志,改为4则不输出任何日志
 	//敏感词
 	fsw.ReadFswDict()

+ 4 - 3
push/src/main.go

@@ -44,9 +44,10 @@ func runJob() {
 		bJobs = false
 		for _, job := range jobs {
 			//单个job内部实现多并发,job间不再支持并发,网络压力太大了
-			job.Execute()
-			util.WriteSysConfig(push.PushConfig)
-
+			util.Try(func() {
+				job.Execute()
+				util.WriteSysConfig(push.PushConfig)
+			}, func(e interface{}) {})
 		}
 		bJobs = true
 	}

+ 16 - 1
push/src/qfw/push/cache.go

@@ -6,11 +6,13 @@ package push
 
 import (
 	"fmt"
-	"gopkg.in/mgo.v2/bson"
 	"log"
 	"qfw/util"
 	"qfw/util/mongodb"
+	"runtime"
 	"strings"
+
+	"gopkg.in/mgo.v2/bson"
 )
 
 type MemberInterest struct {
@@ -24,6 +26,19 @@ type MemberInterest struct {
 
 //初始化缓存,在每次执行任务时调用,
 func InitCache(flag, m_openid string) map[string]*[]*MemberInterest {
+	defer func() {
+		if r := recover(); r != nil {
+			log.Println("[E]", r)
+			for skip := 1; ; skip++ {
+				_, file, line, ok := runtime.Caller(skip)
+				if !ok {
+					break
+				}
+				go log.Printf("%v,%v\n", file, line)
+			}
+		}
+	}()
+
 	cache := make(map[string]*[]*MemberInterest)
 	q := map[string]interface{}{}
 	if m_openid != "" {

+ 1 - 2
weixin/src/qfw/weixin/msgtxtchandler.go

@@ -42,8 +42,7 @@ func MsgTxtHandler(w ResponseWriter, r *Request) {
 		}
 	} else if r.Content == "微信管理" && mids[openid] {
 		UserSession[r.FromUserName] = NewUserSession("wxadmin")
-		w.ReplyText(`您已进入微信管理,请输入指令操作:\n1.查看抽奖模式(指令:f0)\n2.切换抽奖模式(指令:c*,*为数字。如c0(自动模式),c1(手动模式1),c2(手动模式2),c3(手动模式3))\n3.统计抽奖结果(tjr*,tjr120(最近两分钟),tjr120-1200(最近两分钟至最近20分钟之间的))\n4.统计新用户数(tju*)\n5.服务器情况监测(ser0)\n6服务管理(man*,man1重启主程序(man11关闭),man3重启积分(man33关闭),man4重启微信认证(man44关闭))。\n输入q或Q离开。` +
-			`\n7.名片识别(指令:mp*,mp1查看识别状态,mp2关闭识别,mp3开启识别,mp60(数字大于10小于7200)查询最近60秒的识别次数)`)
+		w.ReplyText("您已进入微信管理,请输入指令操作:\n1.查看抽奖模式(指令:f0)\n2.切换抽奖模式(指令:c*,*为数字。如c0(自动模式),c1(手动模式1),c2(手动模式2),c3(手动模式3))\n3.统计抽奖结果(tjr*,tjr120(最近两分钟),tjr120-1200(最近两分钟至最近20分钟之间的))\n4.统计新用户数(tju*)\n5.服务器情况监测(ser0)\n6.服务管理(man*,man1重启主程序(man11关闭),man3重启积分(man33关闭),man4重启微信认证(man44关闭))。\n7.名片识别(指令:mp*,mp1查看识别状态,mp2关闭识别,mp3开启识别,mp60(数字大于10小于7200)查询最近60秒的识别次数)\n输入q或Q离开。")
 		return
 	} else if cj_reg.MatchString(r.Content) { //进入抽奖环节
 		if time.Now().Unix() > 1455552000 { //活动过期 ,过期后,这段代码要删除

+ 1 - 1
weixin/src/qfw/weixin/wxadmin.go

@@ -52,7 +52,7 @@ func processWxAdmin(openid, content string, w ResponseWriter, r *Request) {
 						}
 					} else {
 						num, _ := wutil.GetValFromList(int(var1))
-						resStr = fmt.Sprintf("最近%s秒,识别次数:%d", var1, num)
+						resStr = fmt.Sprintf("最近%d秒,识别次数:%d", var1, num)
 					}
 				case "tjr":
 					//数据库抽奖查看