【热更工具】优化IOS更新卡死的问题

dev_chengFeng
JLIOSM1 2021-08-21 18:51:32 +08:00 committed by gaoxin
parent 6f108e2f5c
commit 4756f15a93
2 changed files with 46 additions and 31 deletions

View File

@ -330,15 +330,21 @@ namespace GameEditor.FrameTool
log.Add("CDN TYPE: " + cdnType); log.Add("CDN TYPE: " + cdnType);
string toolsDir = HotfixWindow._HotFixProjectPath + "/Tools/" + cdnType; string toolsDir = HotfixWindow._HotFixProjectPath + "/Tools/" + cdnType;
log.Add("TOOLS DIR: " + toolsDir); log.Add("TOOLS DIR: " + toolsDir);
string command = string.Format("python UpLoad.py {0} {1} {2}>>{3}", HotfixWindow._HotFixProjectPath + "/Root/" + dir_name, dir_cdn_setting, changeFileName, logPath + logName + ".log"); // MAC机器上pathon脚本中使用多线程会导致unity卡死
int isThread = 1;
#if UNITY_IOS
isThread = 0;
#endif
string command = string.Format("python UpLoad.py {0} {1} {2} {3} >>{4}", HotfixWindow._HotFixProjectPath + "/Root/" + dir_name, dir_cdn_setting, changeFileName, isThread, logPath + logName + ".log");
log.Add("UPLOAD COMMAND: " + command); log.Add("UPLOAD COMMAND: " + command);
ProcessUtil.ProcessCommand(toolsDir, command); ProcessUtil.ProcessCommand(toolsDir, command);
string flushCommand = string.Format("python Flush.py {0}>>{1}", cdn_version.resUrl, logPath + logName + ".log"); string flushCommand = string.Format("python Flush.py {0} >>{1}", cdn_version.resUrl, logPath + logName + ".log");
log.Add("Flush COMMAND: " + flushCommand); log.Add("Flush COMMAND: " + flushCommand);
ProcessUtil.ProcessCommand(toolsDir, flushCommand); ProcessUtil.ProcessCommand(toolsDir, flushCommand);
// write log // write log
EditorUtility.DisplayProgressBar("正在生成Log文件", logName, 1f); string unityLog = changeFileName + "_Unity";
HotFixTool.WriteLog(logPath, logName, log.ToArray()); EditorUtility.DisplayProgressBar("正在生成Log文件", unityLog, 1f);
HotFixTool.WriteLog(logPath, unityLog, log.ToArray());
// git commit // git commit
string commitName = desc + "更新:" + updateName; string commitName = desc + "更新:" + updateName;
EditorUtility.DisplayProgressBar("正在提交到GIT", commitName, 1f); EditorUtility.DisplayProgressBar("正在提交到GIT", commitName, 1f);
@ -691,10 +697,15 @@ namespace GameEditor.FrameTool
log.Add("CDN TYPE: "+ info["cdn_type"]); log.Add("CDN TYPE: "+ info["cdn_type"]);
string toolsDir = _HotFixProjectPath + "/Tools/" + info["cdn_type"]; string toolsDir = _HotFixProjectPath + "/Tools/" + info["cdn_type"];
log.Add("TOOLS DIR: " + toolsDir); log.Add("TOOLS DIR: " + toolsDir);
string command = string.Format("python UpLoad.py {0} {1} {2}>>{3}", _HotFixProjectPath + "/Root/" + hfs.dir_name, hfs.dir_cdn_setting, changeFileName, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log"); // MAC机器上pathon脚本中使用多线程会导致unity卡死
int isThread = 1;
#if UNITY_IOS
isThread = 0;
#endif
string command = string.Format("python UpLoad.py {0} {1} {2} {3} >>{4}", _HotFixProjectPath + "/Root/" + hfs.dir_name, hfs.dir_cdn_setting, changeFileName, isThread, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log");
log.Add("UPLOAD COMMAND: " + command); log.Add("UPLOAD COMMAND: " + command);
ProcessUtil.ProcessCommand(toolsDir, command); ProcessUtil.ProcessCommand(toolsDir, command);
string flushCommand = string.Format("python Flush.py {0}>>{1}", hfs.cdn_version.resUrl, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log"); string flushCommand = string.Format("python Flush.py {0} >>{1}", hfs.cdn_version.resUrl, hfs.path_cdn_setting + "__HotFixLog/" + logName + ".log");
log.Add("Flush COMMAND: " + flushCommand); log.Add("Flush COMMAND: " + flushCommand);
ProcessUtil.ProcessCommand(toolsDir, flushCommand); ProcessUtil.ProcessCommand(toolsDir, flushCommand);
// write log // write log

View File

@ -56,37 +56,41 @@ namespace GameEditor.Util
public static void ProcessCommand(string dir, string[] coms, bool isShowWindow = false) public static void ProcessCommand(string dir, string[] coms, bool isShowWindow = false)
{ {
#if UNITY_IOS #if UNITY_IOS
string shellPath = Path.Combine(dir, "coms.shell"); string shellPath = Path.Combine(dir, "coms.sh");
if (!File.Exists(shellPath)) if (!File.Exists(shellPath))
{ {
File.Create(shellPath).Close(); File.Create(shellPath).Close();
} }
File.WriteAllLines(shellPath, coms); File.WriteAllLines(shellPath, coms);
System.Diagnostics.Process p = new System.Diagnostics.Process(); using(System.Diagnostics.Process p = new System.Diagnostics.Process())
//设置要启动的应用程序 {
p.StartInfo.FileName = "/bin/bash";
//是否使用操作系统shell启动 //设置要启动的应用程序
p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "/bin/zsh";
//接受来自调用程序的输入信息 //是否使用操作系统shell启动
p.StartInfo.RedirectStandardInput = false; p.StartInfo.UseShellExecute = false;
//输出信息 //接受来自调用程序的输入信息
p.StartInfo.RedirectStandardOutput = false; p.StartInfo.RedirectStandardInput = false;
//输出错误 //输出信息
p.StartInfo.RedirectStandardError = false; p.StartInfo.RedirectStandardOutput = false;
//不显示程序窗口 //输出错误
p.StartInfo.CreateNoWindow = !isShowWindow; p.StartInfo.RedirectStandardError = false;
//设置文件夹 //不显示程序窗口
p.StartInfo.WorkingDirectory = dir; p.StartInfo.CreateNoWindow = !isShowWindow;
p.StartInfo.Arguments = shellPath; //设置文件夹
//启动程序 p.StartInfo.WorkingDirectory = dir;
p.Start(); p.StartInfo.Arguments = shellPath;
//等待程序执行完退出进程 //启动程序
p.WaitForExit(); p.Start();
//关闭 //等待程序执行完退出进程
p.Close(); p.WaitForExit();
//删除命令行文件 //关闭
File.Delete(shellPath); p.Close();
//删除命令行文件
File.Delete(shellPath);
}
#else #else
System.Diagnostics.Process p = new System.Diagnostics.Process(); System.Diagnostics.Process p = new System.Diagnostics.Process();
//设置要启动的应用程序 //设置要启动的应用程序