Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

start weed with mount in background

danielfliraf1d207a0fe9b
diff --git a/weed/command/fuse.go b/weed/command/fuse.go
index 74cf2bb70d..b66487bdff 100644
--- a/weed/command/fuse.go
+++ b/weed/command/fuse.go
@@ -22,6 +22,7 @@ func runFuse(cmd *Command, args []string) bool {
rawArgsLen := len(rawArgs)
option := strings.Builder{}
options := []parameter{}
+ masterProcess := true
// first parameter
i := 0
@@ -98,6 +99,8 @@ func runFuse(cmd *Command, args []string) bool {
parameter := options[i]
switch parameter.name {
+ case "child":
+ masterProcess = false
case "arg0":
mountOptions.dir = &parameter.value
case "filer":
@@ -187,6 +190,27 @@ func runFuse(cmd *Command, args []string) bool {
}
}
+ // the master start the child, release it then finish himself
+ if masterProcess {
+ arg0 := os.Args[0]
+ argv := append(os.Args, "-o", "child")
+
+ attr := os.ProcAttr{}
+ child, err := os.StartProcess(arg0, argv, &attr)
+
+ if err != nil {
+ panic(fmt.Errorf("master process can not start child process: %s", err))
+ }
+
+ err = child.Release()
+
+ if err != nil {
+ panic(fmt.Errorf("master process can not release child process: %s", err))
+ }
+
+ return true
+ }
+
// I don't know why PATH environment variable is lost
if err := os.Setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"); err != nil {
panic(fmt.Errorf("setenv: %s", err))