修复 cmd 调用外部程序失败
This commit is contained in:
parent
870c8b7f43
commit
1b50ddaabd
@ -183,22 +183,26 @@ func convertServiceSttings(config *comm.GameConfig, id int, sconfig *comm.Servic
|
||||
//启动服务程序
|
||||
func startService(sseting *core.ServiceSttings) (err error) {
|
||||
var (
|
||||
cmd *exec.Cmd
|
||||
cmd *exec.Cmd
|
||||
command string
|
||||
confpath string = fmt.Sprintf("./conf/%s.yaml", sseting.Id)
|
||||
)
|
||||
switch sseting.Type {
|
||||
case comm.Service_Gateway: //网关服务
|
||||
cmd = exec.Command("./stup.sh", "start", sseting.Id, "gateway", fmt.Sprintf("./conf/%s.yaml", sseting.Id))
|
||||
command = fmt.Sprintf("./stup.sh start %s gateway %s", sseting.Id, confpath)
|
||||
break
|
||||
case comm.Service_Worker: //业务服务
|
||||
cmd = exec.Command("./stup.sh", "start", sseting.Id, "worker", fmt.Sprintf("./conf/%s.yaml", sseting.Id))
|
||||
command = fmt.Sprintf("./stup.sh start %s worker %s", sseting.Id, confpath)
|
||||
break
|
||||
case comm.Service_Mainte: //维护服务
|
||||
cmd = exec.Command("./stup.sh", "start", sseting.Id, "mainte", fmt.Sprintf("./conf/%s.yaml", sseting.Id))
|
||||
command = fmt.Sprintf("./stup.sh start %s mainte %s", sseting.Id, confpath)
|
||||
break
|
||||
default:
|
||||
err = fmt.Errorf("服务类型异常 stype:%s", sseting.Type)
|
||||
return
|
||||
}
|
||||
log.Debug("启动外部命令", log.Field{Key: "cmd", Value: command})
|
||||
cmd = exec.Command("/bin/bash", "-c", command)
|
||||
err = cmd.Run()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user