Right now, I set up it so that a socket is listening to the port and every 10 or so seconds, it will call and get a response. If connection failed it will increment failCount variable. I want it so that once it gets to an amount of times it failed to respond in a row (failCount >10) , then it will execute npm run dev to restart the service that hosts the website
public void SetupServer() { Process p = new Process(); p.StartInfo = new ProcessStartInfo(); p.StartInfo.CreateNoWindow = true; p.StartInfo.WorkingDirectory = "C:/project/client/"; p.StartInfo.FileName = Path.Combine(Environment.SystemDirectory, "cmd.exe"); p.StartInfo.Arguments = string.Format("/C \"{0}\"", "runclient.bat"); p.StartInfo.ErrorDialog = false; p.StartInfo.UseShellExecute = false; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; }
string filename = "runclient.bat"; Process p = new Process(); p.StartInfo = new ProcessStartInfo(); p.StartInfo.WorkingDirectory = @"C:\project\client"; p.StartInfo.FileName = "CMD.EXE"; p.StartInfo.Arguments = $"/K \"{filename}\""); p.Start(); p.WaitForExit();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)