public static void EventSink_Crashed(ServerCrashedEventArgs serverCrashedEventArgs) { try { World.Broadcast(0x35, true, "The server has crashed."); } catch { } }
private static void Restart(ServerCrashedEventArgs e) { Console.Write("Crash: Restarting..."); try { Process.Start(Core.Assembly.Location, Core.Arguments); Console.WriteLine("done"); e.Close = true; } catch { Console.WriteLine("failed"); } }
private static void Restart(ServerCrashedEventArgs e) { logger.Information("Restarting"); try { Process.Start(Core.Assembly.Location, Core.Arguments); logger.Information("Restart done"); e.Close = true; } catch { logger.Error("Restart failed"); } }
private static void Restart(ServerCrashedEventArgs e) { string root = GetRoot(); Console.Write("Crash: Restarting..."); try { Process.Start(Core.ExePath, Core.Arguments); Console.WriteLine("done"); e.Close = true; } catch { Console.WriteLine("failed"); } }
public static void CrashGuard_OnCrash(ServerCrashedEventArgs e) { if (GenerateReport) { GenerateCrashReport(e); } World.WaitForWriteCompletion(); if (SaveBackup) { Backup(); } if (RestartServer) { Restart(e); } }
private static void EventSink_ServerCrashed(ServerCrashedEventArgs obj) { foreach (PokerGame game in GameBackup.PokerGames) { List <PokerPlayer> toRemove = new List <PokerPlayer>(); foreach (PokerPlayer player in game.Players.Players) { if (player.Mobile != null) { toRemove.Add(player); } } foreach (PokerPlayer player in toRemove) { player.SendMessage(0x22, "The server has crashed, and you are now being removed from the poker game and being refunded the money that you currently have."); game.RemovePlayer(player); } } }
public static void CrashGuard_OnCrash(ServerCrashedEventArgs e) { if (GenerateReport) { GenerateCrashReport(e); } World.WaitForWriteCompletion(); if (SaveBackup) { Backup(); } /*if (Core.Service) * e.Close = true; * else */ if (RestartServer) { Restart(e); } }
private static void GenerateCrashReport(ServerCrashedEventArgs e) { Console.Write("Crash: Generating report..."); try { var timeStamp = GetTimeStamp(); var fileName = $"Crash {timeStamp}.log"; var root = Core.BaseDirectory; var filePath = Path.Combine(root, fileName); using (var op = new StreamWriter(filePath)) { var ver = Core.Version; op.WriteLine("Server Crash Report"); op.WriteLine("==================="); op.WriteLine(); op.WriteLine($"ModernUO Version {ver.Major}.{ver.Minor}, Build {ver.Build}.{ver.Revision}"); op.WriteLine("Operating System: {0}", Environment.OSVersion); op.WriteLine(".NET Framework: {0}", Environment.Version); op.WriteLine("Time: {0}", timeStamp); try { op.WriteLine("Mobiles: {0}", World.Mobiles.Count); } catch { // ignored } try { op.WriteLine("Items: {0}", World.Items.Count); } catch { // ignored } op.WriteLine("Exception:"); op.WriteLine(e.Exception); op.WriteLine(); op.WriteLine("Clients:"); try { var states = TcpServer.Instances; op.WriteLine("- Count: {0}", states.Count); foreach (var ns in TcpServer.Instances) { op.Write("+ {0}:", ns); if (ns.Account is Account a) { op.Write(" (account = {0})", a.Username); } var m = ns.Mobile; if (m != null) { op.Write(" (mobile = 0x{0:X} '{1}')", m.Serial.Value, m.Name); } op.WriteLine(); } } catch { op.WriteLine("- Failed"); } } Console.WriteLine("done"); SendEmail(filePath); } catch { Console.WriteLine("failed"); } }
public static void InvokeServerCrashed(ServerCrashedEventArgs e) => ServerCrashed?.Invoke(e);
private static void GenerateCrashReport(ServerCrashedEventArgs e) { logger.Information("Generating crash report"); try { var timeStamp = Utility.GetTimeStamp(); var fileName = $"Crash {timeStamp}.log"; var root = Core.BaseDirectory; var filePath = Path.Combine(root, fileName); using (var op = new StreamWriter(filePath)) { var ver = Core.Version; op.WriteLine("Server Crash Report"); op.WriteLine("==================="); op.WriteLine(); op.WriteLine($"ModernUO Version {ver.Major}.{ver.Minor}, Build {ver.Build}.{ver.Revision}"); op.WriteLine("Operating System: {0}", Environment.OSVersion); op.WriteLine(".NET Framework: {0}", Environment.Version); op.WriteLine("Time: {0}", timeStamp); try { op.WriteLine($"Accounts: {Accounts.Count}"); } catch { // ignored } try { op.WriteLine($"Mobiles: {World.Mobiles.Count}"); } catch { // ignored } try { op.WriteLine($"Items: {World.Items.Count}"); } catch { // ignored } op.WriteLine($"Exception: {e.Exception}"); op.WriteLine(); op.WriteLine("Clients:"); try { var states = TcpServer.Instances; op.WriteLine($"- Count: {states.Count}"); foreach (var ns in TcpServer.Instances) { op.Write($"+ {ns}:"); if (ns.Account is Account a) { op.Write($" (account = {a.Username})"); } var m = ns.Mobile; if (m != null) { op.Write($" (mobile = 0x{m.Serial.Value:X} '{m.Name}')"); } op.WriteLine(); } } catch { op.WriteLine("- Failed"); } } logger.Information("Crash report generated"); SendEmail(filePath); } catch { logger.Error("Crash report generation failed"); } }
private static void GenerateCrashReport(ServerCrashedEventArgs e) { Console.Write("Crash: Generating report..."); try { string timeStamp = GetTimeStamp(); string fileName = $"Crash {timeStamp}.log"; string root = GetRoot(); string filePath = Combine(root, fileName); using (StreamWriter op = new StreamWriter(filePath)) { Version ver = Core.Assembly.GetName().Version; op.WriteLine("Server Crash Report"); op.WriteLine("==================="); op.WriteLine(); op.WriteLine("ModernUO Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision); op.WriteLine("Operating System: {0}", Environment.OSVersion); op.WriteLine(".NET Framework: {0}", Environment.Version); op.WriteLine("Time: {0}", DateTime.UtcNow); try { op.WriteLine("Mobiles: {0}", World.Mobiles.Count); } catch { // ignored } try { op.WriteLine("Items: {0}", World.Items.Count); } catch { // ignored } op.WriteLine("Exception:"); op.WriteLine(e.Exception); op.WriteLine(); op.WriteLine("Clients:"); try { List <NetState> states = TcpServer.Instances; op.WriteLine("- Count: {0}", states.Count); for (int i = 0; i < states.Count; ++i) { NetState state = states[i]; op.Write("+ {0}:", state); if (state.Account is Account a) { op.Write(" (account = {0})", a.Username); } Mobile m = state.Mobile; if (m != null) { op.Write(" (mobile = 0x{0:X} '{1}')", m.Serial.Value, m.Name); } op.WriteLine(); } } catch { op.WriteLine("- Failed"); } } Console.WriteLine("done"); SendEmail(filePath); } catch { Console.WriteLine("failed"); } }
private static void OnServerCrashed(ServerCrashedEventArgs e) { #if !DEBUG e.Close = true; #endif }