From 1b50ddaabd1b36f232540bb43785f1a1fc94950a Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 21 Sep 2022 15:17:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20cmd=20=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E5=A4=96=E9=83=A8=E7=A8=8B=E5=BA=8F=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/cmd/main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/cmd/main.go b/services/cmd/main.go index 623f1b838..c27ea7723 100644 --- a/services/cmd/main.go +++ b/services/cmd/main.go @@ -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 }