|
@ -10,8 +10,10 @@ import ( |
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
sentryhttp "github.com/getsentry/sentry-go/http" |
|
|
"google.golang.org/grpc/reflection" |
|
|
"google.golang.org/grpc/reflection" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/getsentry/sentry-go" |
|
|
"github.com/seaweedfs/seaweedfs/weed/filer" |
|
|
"github.com/seaweedfs/seaweedfs/weed/filer" |
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/glog" |
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
@ -264,6 +266,7 @@ func (fo *FilerOptions) startFiler() { |
|
|
AllowedOrigins: strings.Split(*fo.allowedOrigins, ","), |
|
|
AllowedOrigins: strings.Split(*fo.allowedOrigins, ","), |
|
|
}) |
|
|
}) |
|
|
if nfs_err != nil { |
|
|
if nfs_err != nil { |
|
|
|
|
|
sentry.CaptureException(nfs_err) |
|
|
glog.Fatalf("Filer startup error: %v", nfs_err) |
|
|
glog.Fatalf("Filer startup error: %v", nfs_err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -272,16 +275,21 @@ func (fo *FilerOptions) startFiler() { |
|
|
glog.V(0).Infoln("Start Seaweed filer server", util.Version(), "public at", publicListeningAddress) |
|
|
glog.V(0).Infoln("Start Seaweed filer server", util.Version(), "public at", publicListeningAddress) |
|
|
publicListener, localPublicListener, e := util.NewIpAndLocalListeners(*fo.bindIp, *fo.publicPort, 0) |
|
|
publicListener, localPublicListener, e := util.NewIpAndLocalListeners(*fo.bindIp, *fo.publicPort, 0) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
|
|
|
sentry.CaptureException(e) |
|
|
glog.Fatalf("Filer server public listener error on port %d:%v", *fo.publicPort, e) |
|
|
glog.Fatalf("Filer server public listener error on port %d:%v", *fo.publicPort, e) |
|
|
} |
|
|
} |
|
|
go func() { |
|
|
go func() { |
|
|
if e := http.Serve(publicListener, publicVolumeMux); e != nil { |
|
|
if e := http.Serve(publicListener, publicVolumeMux); e != nil { |
|
|
|
|
|
localHub := sentry.CurrentHub().Clone() |
|
|
|
|
|
localHub.CaptureException(e) |
|
|
glog.Fatalf("Volume server fail to serve public: %v", e) |
|
|
glog.Fatalf("Volume server fail to serve public: %v", e) |
|
|
} |
|
|
} |
|
|
}() |
|
|
}() |
|
|
if localPublicListener != nil { |
|
|
if localPublicListener != nil { |
|
|
go func() { |
|
|
go func() { |
|
|
if e := http.Serve(localPublicListener, publicVolumeMux); e != nil { |
|
|
if e := http.Serve(localPublicListener, publicVolumeMux); e != nil { |
|
|
|
|
|
localHub := sentry.CurrentHub().Clone() |
|
|
|
|
|
localHub.CaptureException(e) |
|
|
glog.Errorf("Volume server fail to serve public: %v", e) |
|
|
glog.Errorf("Volume server fail to serve public: %v", e) |
|
|
} |
|
|
} |
|
|
}() |
|
|
}() |
|
@ -294,6 +302,7 @@ func (fo *FilerOptions) startFiler() { |
|
|
time.Duration(10)*time.Second, |
|
|
time.Duration(10)*time.Second, |
|
|
) |
|
|
) |
|
|
if e != nil { |
|
|
if e != nil { |
|
|
|
|
|
sentry.CaptureException(e) |
|
|
glog.Fatalf("Filer listener error: %v", e) |
|
|
glog.Fatalf("Filer listener error: %v", e) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -301,6 +310,7 @@ func (fo *FilerOptions) startFiler() { |
|
|
grpcPort := *fo.portGrpc |
|
|
grpcPort := *fo.portGrpc |
|
|
grpcL, grpcLocalL, err := util.NewIpAndLocalListeners(*fo.bindIp, grpcPort, 0) |
|
|
grpcL, grpcLocalL, err := util.NewIpAndLocalListeners(*fo.bindIp, grpcPort, 0) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
sentry.CaptureException(err) |
|
|
glog.Fatalf("failed to listen on grpc port %d: %v", grpcPort, err) |
|
|
glog.Fatalf("failed to listen on grpc port %d: %v", grpcPort, err) |
|
|
} |
|
|
} |
|
|
grpcS := pb.NewGrpcServer(security.LoadServerTLS(util.GetViper(), "grpc.filer")) |
|
|
grpcS := pb.NewGrpcServer(security.LoadServerTLS(util.GetViper(), "grpc.filer")) |
|
@ -311,19 +321,22 @@ func (fo *FilerOptions) startFiler() { |
|
|
} |
|
|
} |
|
|
go grpcS.Serve(grpcL) |
|
|
go grpcS.Serve(grpcL) |
|
|
|
|
|
|
|
|
httpS := &http.Server{Handler: defaultMux} |
|
|
|
|
|
|
|
|
httpS := &http.Server{Handler: sentryhttp.New(sentryhttp.Options{}).Handle(defaultMux)} |
|
|
if runtime.GOOS != "windows" { |
|
|
if runtime.GOOS != "windows" { |
|
|
localSocket := *fo.localSocket |
|
|
localSocket := *fo.localSocket |
|
|
if localSocket == "" { |
|
|
if localSocket == "" { |
|
|
localSocket = fmt.Sprintf("/tmp/seaweedfs-filer-%d.sock", *fo.port) |
|
|
localSocket = fmt.Sprintf("/tmp/seaweedfs-filer-%d.sock", *fo.port) |
|
|
} |
|
|
} |
|
|
if err := os.Remove(localSocket); err != nil && !os.IsNotExist(err) { |
|
|
if err := os.Remove(localSocket); err != nil && !os.IsNotExist(err) { |
|
|
|
|
|
sentry.CaptureException(err) |
|
|
glog.Fatalf("Failed to remove %s, error: %s", localSocket, err.Error()) |
|
|
glog.Fatalf("Failed to remove %s, error: %s", localSocket, err.Error()) |
|
|
} |
|
|
} |
|
|
go func() { |
|
|
go func() { |
|
|
// start on local unix socket
|
|
|
// start on local unix socket
|
|
|
filerSocketListener, err := net.Listen("unix", localSocket) |
|
|
filerSocketListener, err := net.Listen("unix", localSocket) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
|
|
|
localHub := sentry.CurrentHub().Clone() |
|
|
|
|
|
localHub.CaptureException(err) |
|
|
glog.Fatalf("Failed to listen on %s: %v", localSocket, err) |
|
|
glog.Fatalf("Failed to listen on %s: %v", localSocket, err) |
|
|
} |
|
|
} |
|
|
httpS.Serve(filerSocketListener) |
|
|
httpS.Serve(filerSocketListener) |
|
@ -332,11 +345,14 @@ func (fo *FilerOptions) startFiler() { |
|
|
if filerLocalListener != nil { |
|
|
if filerLocalListener != nil { |
|
|
go func() { |
|
|
go func() { |
|
|
if err := httpS.Serve(filerLocalListener); err != nil { |
|
|
if err := httpS.Serve(filerLocalListener); err != nil { |
|
|
|
|
|
localHub := sentry.CurrentHub().Clone() |
|
|
|
|
|
localHub.CaptureException(e) |
|
|
glog.Errorf("Filer Fail to serve: %v", e) |
|
|
glog.Errorf("Filer Fail to serve: %v", e) |
|
|
} |
|
|
} |
|
|
}() |
|
|
}() |
|
|
} |
|
|
} |
|
|
if err := httpS.Serve(filerListener); err != nil { |
|
|
if err := httpS.Serve(filerListener); err != nil { |
|
|
|
|
|
sentry.CaptureException(err) |
|
|
glog.Fatalf("Filer Fail to serve: %v", e) |
|
|
glog.Fatalf("Filer Fail to serve: %v", e) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|