From a69f0b62c2a22785b448a4cb29499b4d1410f1ca Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 18 Apr 2022 00:08:31 -0700 Subject: [PATCH] start filer local socket only on non windows fix https://github.com/chrislusf/seaweedfs/issues/2930 --- weed/command/filer.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/weed/command/filer.go b/weed/command/filer.go index dd21ef364..4dbc04a0c 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -5,6 +5,7 @@ import ( "net" "net/http" "os" + "runtime" "time" "google.golang.org/grpc/reflection" @@ -248,18 +249,6 @@ func (fo *FilerOptions) startFiler() { glog.Fatalf("Filer listener error: %v", e) } - // start on local unix socket - if *fo.localSocket == "" { - *fo.localSocket = fmt.Sprintf("/tmp/seaweefs-filer-%d.sock", *fo.port) - if err := os.Remove(*fo.localSocket); err != nil && !os.IsNotExist(err) { - glog.Fatalf("Failed to remove %s, error: %s", *fo.localSocket, err.Error()) - } - } - filerSocketListener, err := net.Listen("unix", *fo.localSocket) - if err != nil { - glog.Fatalf("Failed to listen on %s: %v", *fo.localSocket, err) - } - // starting grpc server grpcPort := *fo.portGrpc grpcL, grpcLocalL, err := util.NewIpAndLocalListeners(*fo.bindIp, grpcPort, 0) @@ -275,9 +264,22 @@ func (fo *FilerOptions) startFiler() { go grpcS.Serve(grpcL) httpS := &http.Server{Handler: defaultMux} - go func() { - httpS.Serve(filerSocketListener) - }() + if runtime.GOOS != "windows" { + if *fo.localSocket == "" { + *fo.localSocket = fmt.Sprintf("/tmp/seaweefs-filer-%d.sock", *fo.port) + if err := os.Remove(*fo.localSocket); err != nil && !os.IsNotExist(err) { + glog.Fatalf("Failed to remove %s, error: %s", *fo.localSocket, err.Error()) + } + } + go func() { + // start on local unix socket + filerSocketListener, err := net.Listen("unix", *fo.localSocket) + if err != nil { + glog.Fatalf("Failed to listen on %s: %v", *fo.localSocket, err) + } + httpS.Serve(filerSocketListener) + }() + } if filerLocalListener != nil { go func() { if err := httpS.Serve(filerLocalListener); err != nil {