Golang語言社群--訊息觸發伺服器啟動基礎模組分享
阿新 • • 發佈:2022-05-05
// 寫入部署文字檔案資料 func (this *OnlineUser) GM_SetGameFirmsAccountnfo_Of_TXT_Fun(StrServerName string, StrServerPort string) bool { Log_Eio.Log("Entry GM_SetGameFirmsAccountnfo_Of_TXT_Fun") fileName := "../server.txt" dstFile, err := os.Create(fileName) if err != nil { Log_Eio.Log("os.Create(fileName):", err.Error()) dstFile.Close() return false } s := StrServerName + " " + StrServerPort dstFile.WriteString(s) dstFile.Close() Log_Eio.Log("server.txt data:", s) return true } // 啟動指令碼檔案 func (this *OnlineUser) GM_SetGameFirmsAccountnfo_Of_Shell_Fun() bool { Log_Eio.Log("Entry GM_SetGameFirmsAccountnfo_Of_Shell_Fun") cmd := exec.Command("/bin/sh", "./server_start.sh") bytes, err := cmd.Output() if err != nil { Log_Eio.Log("cmd.Output:", err.Error()) return false } Log_Eio.Log(string(bytes)) return true }