【修改主文件判断】

This commit is contained in:
weizhihong 2023-10-08 09:34:00 +08:00
parent 3fe1b3e330
commit a21ace47dd
3 changed files with 8 additions and 4 deletions

View File

@ -105,6 +105,9 @@ func (server *udpServer) OnTraffic(c gnet.Conn) gnet.Action {
}
func RunUdpServer() {
if !config.Config.Dynamics.Open {
return
}
server := &udpServer{addr: fmt.Sprintf("udp://:%d", config.Config.Dynamics.UdpLocalPort), multicore: false}
err := gnet.Run(server, server.addr, gnet.WithMulticore(server.multicore))
zap.L().Fatal("udp服务启动失败", zap.Error(err))

View File

@ -40,10 +40,8 @@ func main() {
docs.SwaggerInfo.Title = "CBTC测试系统API"
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
if config.Config.Dynamics.Open {
go dynamics.RunUdpServer()
go vobc.RunUdpServer()
}
go dynamics.RunUdpServer()
go vobc.RunUdpServer()
serverConfig := config.Config.Server
if serverConfig.Port == 0 {

View File

@ -103,6 +103,9 @@ func RegisterTrainInfoHandler(handler VobcDataHandler) {
// 创建UDP服务
func RunUdpServer() {
if !config.Config.Dynamics.Open {
return
}
server := &udpServer{addr: fmt.Sprintf("udp://:%d", config.Config.Vobc.LocalPort), multicore: false}
err := gnet.Run(server, server.addr, gnet.WithMulticore(server.multicore))
zap.L().Fatal("vobc udp服务启动失败", zap.Error(err))