aboutsummaryrefslogtreecommitdiff
path: root/weed/command/volume.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-03-13 10:16:32 -0800
committerChris Lu <chris.lu@gmail.com>2021-03-13 10:16:32 -0800
commitf9a7c45e9a223d8876d4baafb3d03ac974c39cfb (patch)
tree78e87f0cfb847104a4a38a60937e3f2034c22298 /weed/command/volume.go
parent2a68ddb963d2ad3810b799487fa66059790fb105 (diff)
downloadseaweedfs-f9a7c45e9a223d8876d4baafb3d03ac974c39cfb.tar.xz
seaweedfs-f9a7c45e9a223d8876d4baafb3d03ac974c39cfb.zip
udp hangs
Diffstat (limited to 'weed/command/volume.go')
-rw-r--r--weed/command/volume.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go
index 0e8224dbc..002227a10 100644
--- a/weed/command/volume.go
+++ b/weed/command/volume.go
@@ -29,6 +29,7 @@ import (
stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/pin/tftp"
)
var (
@@ -256,6 +257,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
// starting tcp server
if *v.enableTcp {
go v.startTcpService(volumeServer)
+ go v.startUdpService(volumeServer)
}
// starting the cluster http server
@@ -378,10 +380,10 @@ func (v VolumeServerOptions) startClusterHttpService(handler http.Handler) httpd
func (v VolumeServerOptions) startTcpService(volumeServer *weed_server.VolumeServer) {
listeningAddress := *v.bindIp + ":" + strconv.Itoa(*v.port+20000)
- glog.V(0).Infoln("Start Seaweed volume server", util.Version(), "tcp at", listeningAddress)
+ glog.V(0).Infoln("Start Seaweed volume server", util.Version(), "TCP at", listeningAddress)
listener, e := util.NewListener(listeningAddress, 0)
if e != nil {
- glog.Fatalf("Volume server listener error on %s:%v", listeningAddress, e)
+ glog.Fatalf("Volume server TCP on %s:%v", listeningAddress, e)
}
defer listener.Close()
@@ -394,3 +396,13 @@ func (v VolumeServerOptions) startTcpService(volumeServer *weed_server.VolumeSer
go volumeServer.HandleTcpConnection(c)
}
}
+
+func (v VolumeServerOptions) startUdpService(volumeServer *weed_server.VolumeServer) {
+ tftpServer := tftp.NewServer(volumeServer.UdpReadHandler, volumeServer.UdpWriteHandler)
+ listeningAddress := *v.bindIp + ":" + strconv.Itoa(*v.port+20001)
+
+ glog.V(0).Infoln("Start Seaweed volume server", util.Version(), "UDP at", listeningAddress)
+ if e:= tftpServer.ListenAndServe(listeningAddress); e != nil {
+ glog.Fatalf("Volume server UDP on %s:%v", listeningAddress, e)
+ }
+}