This commit is contained in:
parhelia512 2025-09-18 15:14:31 +08:00 committed by GitHub
parent ecfa30ef0c
commit 35692ea6fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,6 +58,12 @@ func (s *server) Start(in *gen.LoadConfigReq, out *gen.ErrorResp) (_ error) {
}
if *in.NeedExtraProcess {
args, e := shlex.Split(*in.ExtraProcessArgs)
if e != nil {
err = E.Cause(e, "Failed to parse args")
return
}
if in.ExtraProcessConf != nil {
extraConfPath := *in.ExtraProcessConfDir + string(os.PathSeparator) + "extra.conf"
f, e := os.OpenFile(extraConfPath, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 700)
if e != nil {
@ -70,17 +76,13 @@ func (s *server) Start(in *gen.LoadConfigReq, out *gen.ErrorResp) (_ error) {
return
}
_ = f.Close()
args, e := shlex.Split(*in.ExtraProcessArgs)
if e != nil {
err = E.Cause(e, "Failed to parse args")
return
}
for idx, arg := range args {
if strings.Contains(arg, "%s") {
args[idx] = fmt.Sprintf(arg, extraConfPath)
break
}
}
}
extraProcess = process.NewProcess(*in.ExtraProcessPath, args, *in.ExtraNoOut)
err = extraProcess.Start()