|
@@ -10,11 +10,17 @@ import (
|
|
|
)
|
|
|
|
|
|
func ListenTcp() {
|
|
|
+ var listen net.Listener
|
|
|
+ var err error
|
|
|
// 监听当前的tcp连接
|
|
|
- listen, err := net.Listen("tcp", "0.0.0.0:9200")
|
|
|
- if err != nil {
|
|
|
- logger.Logger.Errorf("listen failed, err:%v", err)
|
|
|
- return
|
|
|
+ for {
|
|
|
+ listen, err = net.Listen("tcp", "0.0.0.0:9200")
|
|
|
+ if err != nil {
|
|
|
+ logger.Logger.Errorf("Listen failed, err: %v. Retrying in 5 seconds...", err)
|
|
|
+ time.Sleep(5 * time.Second) // 休眠一段时间后重试
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ break // 成功监听后退出循环
|
|
|
}
|
|
|
|
|
|
tracker := NewConnectionTracker() //创建连接检测器
|