aboutsummaryrefslogtreecommitdiff
path: root/weed/command/mount_std.go
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2022-04-05 13:29:46 +0500
committerKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2022-04-05 13:29:46 +0500
commit17c6e8e39fd3dd2d3220032bd2ef0d537514257d (patch)
tree462ede8ea61484114f2bde09b6eeb0e9e37b2ab6 /weed/command/mount_std.go
parentb7cdde14ae44508c59dbf5cf3835a0a68ba1aabb (diff)
parent3176bf126ae21395b26d6f6531c05fb571fac54f (diff)
downloadseaweedfs-17c6e8e39fd3dd2d3220032bd2ef0d537514257d.tar.xz
seaweedfs-17c6e8e39fd3dd2d3220032bd2ef0d537514257d.zip
Merge branch 'new_master' into hashicorp_raft
# Conflicts: # go.mod # go.sum
Diffstat (limited to 'weed/command/mount_std.go')
-rw-r--r--weed/command/mount_std.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go
index d865e053f..7926c9cdc 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)