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,27 +58,29 @@ func (s *server) Start(in *gen.LoadConfigReq, out *gen.ErrorResp) (_ error) {
} }
if *in.NeedExtraProcess { if *in.NeedExtraProcess {
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 {
err = E.Cause(e, "Failed to open extra.conf")
return
}
_, e = f.WriteString(*in.ExtraProcessConf)
if e != nil {
err = E.Cause(e, "Failed to write extra.conf")
return
}
_ = f.Close()
args, e := shlex.Split(*in.ExtraProcessArgs) args, e := shlex.Split(*in.ExtraProcessArgs)
if e != nil { if e != nil {
err = E.Cause(e, "Failed to parse args") err = E.Cause(e, "Failed to parse args")
return return
} }
for idx, arg := range args { if in.ExtraProcessConf != nil {
if strings.Contains(arg, "%s") { extraConfPath := *in.ExtraProcessConfDir + string(os.PathSeparator) + "extra.conf"
args[idx] = fmt.Sprintf(arg, extraConfPath) f, e := os.OpenFile(extraConfPath, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 700)
break if e != nil {
err = E.Cause(e, "Failed to open extra.conf")
return
}
_, e = f.WriteString(*in.ExtraProcessConf)
if e != nil {
err = E.Cause(e, "Failed to write extra.conf")
return
}
_ = f.Close()
for idx, arg := range args {
if strings.Contains(arg, "%s") {
args[idx] = fmt.Sprintf(arg, extraConfPath)
break
}
} }
} }