public static void Test(Server s) { DateTime start = DateTime.Now; DateTime timeout = DateTime.Now.Add(Timeout); s.SendCommand("whitelist"); while (true) { if (s.LastReceived > start) { break; } #if DEBUG Console.WriteLine("Watchdog waiting"); #endif if (DateTime.Now < timeout) { System.Threading.Thread.Sleep(100); continue; } //Triggered BackendManager.Log(new Exception("Watchdog: " + s.Name)); s.Kill(); break; } }
void Run() { try { SendLine(BackendManager.RunningServers()); while (active) { try { if (Program.Exit.WaitOne(0)) { break; } string line = reader.ReadLine(); if (line == null) { return; } line = line.Trim(); if (line == "") { continue; } string[] args = line.Split(' ', '\t'); ParseCommand(args); } catch (InvalidArgumentException ia) { string error = "ERROR\t" + ia.Message; Console.Error.WriteLine(error); SendLine(error); continue; } catch (Exception e) { BackendManager.Log(e); return; } } } finally { BackendManager.ClientClosed(this); tcp.Close(); } }
public void SendLine(string line) { if (Echo == false) { return; } try { writer.WriteLine(line); writer.Flush(); } catch (IOException) { return; } catch (Exception e) { BackendManager.Log(e); } }