Commit 58ec53d6 by 刘豪

修复退出协程未删除映射的bug

parent 1fc283e0
Showing with 3 additions and 2 deletions
......@@ -87,7 +87,7 @@ func getCtxHand(fileMap map[string]map[Client]bool) func(ctx iris.Context) {
utils.Log.Infof("%s has been monitored", filePath)
} else {
// 监控文件
go monitor(filePath, cli)
go monitor(fileMap, filePath)
l := make(map[Client]bool)
l[*cli] = true
fileMap[filePath] = l
......
......@@ -7,7 +7,7 @@ import (
)
// 监控日志文件
func monitor(filePath string, cli *Client) {
func monitor(fileMap map[string]map[Client]bool, filePath string) {
defer func() {
if err := recover(); err != nil {
utils.Log.Errorf("defer [seelog] error:%+v", err)
......@@ -62,6 +62,7 @@ func monitor(filePath string, cli *Client) {
// 防止协程开启太多
if startMonitorTime < (time.Now().Unix() - 3600) {
utils.Log.Info("超过1小时限制时间,退出协程")
delete(fileMap, filePath)
return
} else {
time.Sleep(500 * time.Millisecond)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment