From 3783cfe759c249aeabc57b1ffde9b4eb909b0e56 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 13 Jun 2023 23:04:16 +1000 Subject: [PATCH] main: Added error checks in case HSD doesn't start --- FireWallet/MainForm.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/FireWallet/MainForm.cs b/FireWallet/MainForm.cs index 4bf522f..0385354 100644 --- a/FireWallet/MainForm.cs +++ b/FireWallet/MainForm.cs @@ -210,10 +210,17 @@ namespace FireWallet { hsdProcess.StartInfo.CreateNoWindow = hideScreen; + if (hideScreen) + { + hsdProcess.StartInfo.RedirectStandardError = true; + } else + { + hsdProcess.StartInfo.RedirectStandardError = false; + } + hsdProcess.StartInfo.RedirectStandardInput = true; hsdProcess.StartInfo.RedirectStandardOutput = false; hsdProcess.StartInfo.UseShellExecute = false; - hsdProcess.StartInfo.RedirectStandardError = false; hsdProcess.StartInfo.FileName = "node.exe"; hsdProcess.StartInfo.Arguments = dir + "hsd/bin/hsd --agent=FireWallet --index-tx --index-address --api-key " + nodeSettings["Key"]; @@ -225,6 +232,24 @@ namespace FireWallet hsdProcess.Start(); // Wait for HSD to start await Task.Delay(2000); + + // Check if HSD is running + if (hsdProcess.HasExited) + { + AddLog("HSD Failed to start"); + AddLog(hsdProcess.StandardError.ReadToEnd()); + NotifyForm Notifyinstall = new NotifyForm("HSD Failed to start\nPlease check the logs"); + Notifyinstall.ShowDialog(); + Notifyinstall.Dispose(); + + // Wait for the notification to show + await Task.Delay(1000); + this.Close(); + + await Task.Delay(1000); + return false; + } + } catch (Exception ex) { @@ -232,9 +257,7 @@ namespace FireWallet AddLog(ex.Message); this.Close(); await Task.Delay(1000); - AddLog("Close Failed"); } - } } timerNodeStatus.Start();