mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 07:17:25 +08:00
start weed with mount in background
This commit is contained in:
@@ -22,6 +22,7 @@ func runFuse(cmd *Command, args []string) bool {
|
|||||||
rawArgsLen := len(rawArgs)
|
rawArgsLen := len(rawArgs)
|
||||||
option := strings.Builder{}
|
option := strings.Builder{}
|
||||||
options := []parameter{}
|
options := []parameter{}
|
||||||
|
masterProcess := true
|
||||||
|
|
||||||
// first parameter
|
// first parameter
|
||||||
i := 0
|
i := 0
|
||||||
@@ -98,6 +99,8 @@ func runFuse(cmd *Command, args []string) bool {
|
|||||||
parameter := options[i]
|
parameter := options[i]
|
||||||
|
|
||||||
switch parameter.name {
|
switch parameter.name {
|
||||||
|
case "child":
|
||||||
|
masterProcess = false
|
||||||
case "arg0":
|
case "arg0":
|
||||||
mountOptions.dir = ¶meter.value
|
mountOptions.dir = ¶meter.value
|
||||||
case "filer":
|
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
|
// 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 {
|
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))
|
panic(fmt.Errorf("setenv: %s", err))
|
||||||
|
Reference in New Issue
Block a user