aa
This commit is contained in:
@@ -142,6 +142,8 @@ func ListenTcp() {
|
|||||||
globals.SugarLogger.Debugf("begin listenTcp port 8000......")
|
globals.SugarLogger.Debugf("begin listenTcp port 8000......")
|
||||||
go HandleTcpMessages()
|
go HandleTcpMessages()
|
||||||
go HandleCheckTcpHeart()
|
go HandleCheckTcpHeart()
|
||||||
|
go doPrint(printMsgChanFail)
|
||||||
|
go doPrint2(printMsgChan)
|
||||||
for {
|
for {
|
||||||
c, err := l.Accept()
|
c, err := l.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -272,7 +274,8 @@ func doPrint(printMsgChanFail chan *model.PrintMsg) (err error) {
|
|||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
printMsg := <-printMsgChanFail
|
select {
|
||||||
|
case printMsg, _ := <-printMsgChanFail:
|
||||||
var (
|
var (
|
||||||
data []byte
|
data []byte
|
||||||
c net.Conn
|
c net.Conn
|
||||||
@@ -303,6 +306,7 @@ func doPrint(printMsgChanFail chan *model.PrintMsg) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printStatus2JxStatus(printStatus string) (status int) {
|
func printStatus2JxStatus(printStatus string) (status int) {
|
||||||
@@ -359,7 +363,6 @@ func HandleTcpMessages() {
|
|||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
//一直读?
|
//一直读?
|
||||||
time.Sleep(time.Second / 2)
|
|
||||||
prints, _ := dao.GetPrintMsgs(db, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), offset, pageSize)
|
prints, _ := dao.GetPrintMsgs(db, []int{printMsgWait}, time.Now().Add(-time.Hour*3), time.Now(), offset, pageSize)
|
||||||
for _, printMsg := range prints {
|
for _, printMsg := range prints {
|
||||||
printMsgChan <- printMsg
|
printMsgChan <- printMsg
|
||||||
@@ -372,7 +375,8 @@ func doPrint2(printMsgChan chan *model.PrintMsg) (err error) {
|
|||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
for {
|
for {
|
||||||
printMsg := <-printMsgChan
|
select {
|
||||||
|
case printMsg, _ := <-printMsgChan:
|
||||||
var (
|
var (
|
||||||
data []byte
|
data []byte
|
||||||
c net.Conn
|
c net.Conn
|
||||||
@@ -419,6 +423,7 @@ func doPrint2(printMsgChan chan *model.PrintMsg) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleCheckTcpHeart() {
|
func HandleCheckTcpHeart() {
|
||||||
|
|||||||
Reference in New Issue
Block a user