This commit is contained in:
zhouyuyan
2017-09-11 17:00:02 +08:00
parent cc1b3239ad
commit 5601632a33
22 changed files with 28 additions and 1251 deletions

View File

@@ -3,13 +3,15 @@ package broker
import (
"crypto/tls"
"hmq/lib/acl"
"hmq/packets"
"net"
"net/http"
"runtime/debug"
"sync"
"sync/atomic"
"time"
"github.com/eclipse/paho.mqtt.golang/packets"
"golang.org/x/net/websocket"
log "github.com/cihub/seelog"
@@ -77,20 +79,21 @@ func (b *Broker) Start() {
if len(b.config.Cluster.Routes) > 0 {
b.ConnectToRouters()
}
// go StateMonitor()
go StateMonitor()
}
// func StateMonitor() {
// v, _ := mem.VirtualMemory()
// timeSticker := time.NewTicker(time.Second * 5)
// for {
// select {
// case <-timeSticker.C:
// fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
// }
// }
// }
func StateMonitor() {
// v, _ := mem.VirtualMemory()
timeSticker := time.NewTicker(time.Second * 30)
for {
select {
case <-timeSticker.C:
debug.FreeOSMemory()
// fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
}
}
}
func (b *Broker) StartWebsocketListening() {
path := b.config.WsPath