mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-01 19:28:05 +08:00
[FIX] fix sub docker log websocket periodic disconnect bug
This commit is contained in:
parent
87c784bcdf
commit
7a23fc874a
8
Makefile
8
Makefile
@ -58,14 +58,6 @@ else ifeq ($(WHAT),builder)
|
||||
${BIN_PATH}/${BASE_NAME}-chaos \
|
||||
--log-level=debug \
|
||||
--mysql="root:@tcp(127.0.0.1:3306)/region"
|
||||
else ifeq ($(WHAT),eventlog)
|
||||
${BIN_PATH}/${BASE_NAME}-eventlog \
|
||||
--log.level=debug --discover.etcd.addr=http://127.0.0.1:2379 \
|
||||
--db.url="root:@tcp(127.0.0.1:3306)/event" \
|
||||
--dockerlog.mode=stream \
|
||||
--message.dockerlog.handle.core.number=2 \
|
||||
--message.garbage.file="/tmp/garbage.log" \
|
||||
--docker.log.homepath="/Users/qingguo/tmp"
|
||||
else
|
||||
test/run/run_${WHAT}.sh ${BIN_PATH}/${BASE_NAME}-$(WHAT)
|
||||
endif
|
||||
|
@ -273,6 +273,11 @@ func (r *dockerLogEventBarrel) gcPersistence() {
|
||||
r.persistenceBarrel = append(r.persistenceBarrel, r.barrel...) //数据转到持久化等候队列
|
||||
r.barrel = nil
|
||||
}
|
||||
func (r *dockerLogEventBarrel) GetSubChanLength() int {
|
||||
r.subLock.Lock()
|
||||
defer r.subLock.Unlock()
|
||||
return len(r.subSocketChan)
|
||||
}
|
||||
|
||||
type monitorMessageBarrel struct {
|
||||
barrel []*db.EventLogMessage
|
||||
|
@ -152,8 +152,11 @@ func (h *dockerLogStore) handle() []string {
|
||||
var gcEvent []string
|
||||
for k, v := range h.barrels {
|
||||
if v.updateTime.Add(time.Minute * 1).Before(time.Now()) { // barrel 超时未收到消息
|
||||
h.saveBeforeGc(k, v)
|
||||
gcEvent = append(gcEvent, k)
|
||||
//gc without client link
|
||||
if v.GetSubChanLength() == 0 {
|
||||
h.saveBeforeGc(k, v)
|
||||
gcEvent = append(gcEvent, k)
|
||||
}
|
||||
}
|
||||
if v.persistenceTime.Add(time.Minute * 2).Before(time.Now()) { //超过2分钟未持久化 间隔需要大于1分钟。以分钟为单位
|
||||
if len(v.barrel) > 0 {
|
||||
@ -178,6 +181,7 @@ func (h *dockerLogStore) gcRun() {
|
||||
h.pool.Put(barrel) //放回对象池
|
||||
delete(h.barrels, id)
|
||||
h.barrelSize--
|
||||
h.log.Debugf("docker log barrel(%s) gc complete", id)
|
||||
}
|
||||
}
|
||||
useTime := time.Now().UnixNano() - t.UnixNano()
|
||||
@ -205,7 +209,6 @@ func (h *dockerLogStore) saveBeforeGc(eventID string, v *dockerLogEventBarrel) {
|
||||
}
|
||||
v.persistenceBarrel = nil
|
||||
v.persistencelock.Unlock()
|
||||
h.log.Debugf("Docker message store complete gc barrel(%s)", v.name)
|
||||
}
|
||||
func (h *dockerLogStore) InsertGarbageMessage(message ...*db.EventLogMessage) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user