Commit bb08e140 by lichenggang

初始化可以监听全部内容

- 但是监听状态会被保存
parent 4da715ae
Showing with 14 additions and 2 deletions
...@@ -26,9 +26,21 @@ func monitor(filePath string) { ...@@ -26,9 +26,21 @@ func monitor(filePath string) {
} }
break break
} }
offset := fileInfo.Size() offset := fileInfo.Size()
//allready_msg := make([]byte, offset)
//初始监听时加载全部内容
allcontent_msg := make([]byte, offset)
allcontent_file, err := os.Open(filePath)
if err != nil {
log.Printf("[seelog] error:%v", err.Error())
}
_, err = allcontent_file.Read(allcontent_msg)
if err != nil {
log.Printf("[seelog] error:%v", err.Error())
}
all_content := filename + "$$" + string(allcontent_msg)
manager.broadcast <- []byte(all_content)
allcontent_file.Close()
for { for {
fileInfo, err = os.Stat(filePath) fileInfo, err = os.Stat(filePath)
......
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