1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-06-02 08:40:20 +02:00

Merge pull request #2141 from danielflira/feature-background-fuse

start "weed fuse" in background
This commit is contained in:
Chris Lu 2021-06-19 23:05:16 -07:00 committed by GitHub
commit 117f8e0bc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))