【修改主文件判断】
This commit is contained in:
parent
3fe1b3e330
commit
a21ace47dd
|
@ -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))
|
||||
|
|
6
main.go
6
main.go
|
@ -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 {
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue