diff options
| author | guosj <515878133@qq.com> | 2022-04-19 09:25:32 +0800 |
|---|---|---|
| committer | guosj <515878133@qq.com> | 2022-04-19 09:25:32 +0800 |
| commit | 82ee31965dd7a1ad2d348c7e9dadb254744bf9b0 (patch) | |
| tree | 593eb933dffc877010c761b2c55ec6c73875e9a3 /weed/command/mount_std.go | |
| parent | 5c9a3bb8cf68ed99acb53dd548c92b54744d7fd7 (diff) | |
| parent | e6ebafc094dc0ce0e3b0a68d7735f52a544bc479 (diff) | |
| download | seaweedfs-82ee31965dd7a1ad2d348c7e9dadb254744bf9b0.tar.xz seaweedfs-82ee31965dd7a1ad2d348c7e9dadb254744bf9b0.zip | |
Merge branch 'master' of https://github.com/chrislusf/seaweedfs into chrislusf-master
Diffstat (limited to 'weed/command/mount_std.go')
| -rw-r--r-- | weed/command/mount_std.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index d865e053f..1d929dc96 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -12,9 +12,12 @@ import ( "github.com/chrislusf/seaweedfs/weed/mount/unmount" "github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" + "github.com/chrislusf/seaweedfs/weed/pb/mount_pb" "github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/hanwen/go-fuse/v2/fuse" + "google.golang.org/grpc/reflection" + "net" "net/http" "os" "os/user" @@ -98,6 +101,22 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { unmount.Unmount(dir) + // start on local unix socket + if *option.localSocket == "" { + mountDirHash := util.HashToInt32([]byte(dir)) + if mountDirHash < 0 { + mountDirHash = -mountDirHash + } + *option.localSocket = fmt.Sprintf("/tmp/seaweefs-mount-%d.sock", mountDirHash) + } + if err := os.Remove(*option.localSocket); err != nil && !os.IsNotExist(err) { + glog.Fatalf("Failed to remove %s, error: %s", *option.localSocket, err.Error()) + } + montSocketListener, err := net.Listen("unix", *option.localSocket) + if err != nil { + glog.Fatalf("Failed to listen on %s: %v", *option.localSocket, err) + } + // detect mount folder mode if *option.dirAutoCreate { os.MkdirAll(dir, os.FileMode(0777)&^umask) @@ -229,6 +248,11 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { unmount.Unmount(dir) }) + grpcS := pb.NewGrpcServer() + mount_pb.RegisterSeaweedMountServer(grpcS, seaweedFileSystem) + reflection.Register(grpcS) + go grpcS.Serve(montSocketListener) + seaweedFileSystem.StartBackgroundTasks() fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH) |
