gongqiuhong 1 tahun lalu
induk
melakukan
b682894060

+ 7 - 2
Service/GpuCgServer/AddIns/GpuCgHelper.cs

@@ -59,8 +59,7 @@ namespace GpuCgServer
             var exeFile = Path.Combine(exePath, exeName);
             if (!File.Exists(exeFile))
                 throw new Exception($"文件[{exeFile}]不存在");
-            Stopwatch sw = new Stopwatch();
-            sw.Start();
+            
             Process p = new Process();
             p.StartInfo.WorkingDirectory = exePath;
             p.StartInfo.FileName = exeFile;
@@ -69,6 +68,8 @@ namespace GpuCgServer
             p.StartInfo.RedirectStandardError = true;
             p.StartInfo.RedirectStandardOutput = true;
             p.StartInfo.UseShellExecute = false;
+            Stopwatch sw = new Stopwatch();
+            sw.Start();
             p.Start();
             var succeed = p.WaitForExit(timeoutSeconds * 1000);
             if (!succeed)
@@ -77,6 +78,10 @@ namespace GpuCgServer
             }
             var res = p.StandardOutput.ReadToEnd();
             sw.Stop();
+            if (sw.ElapsedMilliseconds < 800)
+            {
+                throw new Exception("没有GPU");
+            }
             List<GpuCgResponseDto> list = new List<GpuCgResponseDto>();
             //3:-0.000*-0.00054.553+72.917*0.000*37.756+-72.917*0.000*37.671+
             if (res.Length<3)

+ 2 - 2
Service/GpuCgServer/Controllers/GpuCgController.cs

@@ -48,8 +48,8 @@ namespace GpuCgServer.Controllers
             }
             catch (Exception ex)
             {
-                Serilog.Log.Error(ex, "执行GPU参估异常");
-                return Error<List<GpuCgResponseDto>>($"执行GPU参估异常");
+                Serilog.Log.Error(ex, $"执行GPU参估异常,{ex.Message}");
+                return Error<List<GpuCgResponseDto>>($"执行GPU参估异常,{ex.Message}");
             }
         }