internal static void PreformShutDown() { if (ShutdownInitiated) { Console.WriteLine("Avviso: processo di arresto inizializzato..."); return; } //LowPriorityWorker.DestroyJson(); ShutdownInitiated = true; var builder = new StringBuilder(); var ShutdownStart = DateTime.Now; var MessaMessage = DateTime.Now; AppendTimeStampWithComment(ref builder, MessaMessage, "Hotel pre-warning"); Game.StopGameLoop(); Console.WriteLine("Avviso: game loop arrestato."); var ConnectionClose = DateTime.Now; Console.WriteLine("Avviso: server in fase di chiusura..."); Console.Title = "Avviso: server chiuso con successo."; GetConnectionManager().Destroy(); AppendTimeStampWithComment(ref builder, ConnectionClose, "Avviso: socket chiuso."); var sConnectionClose = DateTime.Now; GetGame().GetClientManager().CloseAll(); AppendTimeStampWithComment(ref builder, sConnectionClose, "Avviso: pre-salvataggio furni e chiusura connessione..."); var RoomRemove = DateTime.Now; Console.WriteLine("Avviso: salvataggio delle stanze."); Game.GetRoomManager().RemoveAllRooms(); AppendTimeStampWithComment(ref builder, RoomRemove, "Room destructor"); var DbSave = DateTime.Now; AppendTimeStampWithComment(ref builder, DbSave, "Database pre-save"); var connectionShutdown = DateTime.Now; ConnectionManager.Destroy(); AppendTimeStampWithComment(ref builder, connectionShutdown, "Connection shutdown"); var gameDestroy = DateTime.Now; Game.Destroy(); AppendTimeStampWithComment(ref builder, gameDestroy, "Game destroy"); var databaseDeconstructor = DateTime.Now; Console.WriteLine("Avviso: completamento chiusura del database..."); manager.destroy(); Game.GetMuteManager().saveToDatabase(); AppendTimeStampWithComment(ref builder, databaseDeconstructor, "Database shutdown"); var timeUsedOnShutdown = DateTime.Now - ShutdownStart; builder.AppendLine("Avviso: tempo totale di chiusura del processo: " + TimeSpanToString(timeUsedOnShutdown)); builder.AppendLine(); Logging.LogShutdown(builder); Console.WriteLine("Avviso: sistema completamente arrestato."); Environment.Exit(Environment.ExitCode); }
internal static void PreformShutDown() { if (ShutdownInitiated) { Console.WriteLine("[Otanix] @ Alerta: Processo de shutdown inicializado. Retornando ..."); return; } //LowPriorityWorker.DestroyJson(); ShutdownInitiated = true; var builder = new StringBuilder(); var ShutdownStart = DateTime.Now; var MessaMessage = DateTime.Now; AppendTimeStampWithComment(ref builder, MessaMessage, "Hotel pre-warning"); Game.StopGameLoop(); Console.Write(@"[Otanix] @ Alerta: Game loop parado"); var ConnectionClose = DateTime.Now; Console.WriteLine("[Otanix] @ Alerta: Servidor sendo finalizado..."); Console.Title = "[Otanix] @ Alerta: Otanix foi desligado com sucesso!"; GetConnectionManager().Destroy(); AppendTimeStampWithComment(ref builder, ConnectionClose, "[Otanix] @ Alerta: Socket fechado"); var sConnectionClose = DateTime.Now; GetGame().GetClientManager().CloseAll(); AppendTimeStampWithComment(ref builder, sConnectionClose, "[Otanix] @ Alerta: Furni pre-save and connection close"); var RoomRemove = DateTime.Now; Console.WriteLine("[Otanix] @ Alerta: SALVANDO OS QUARTOS"); Game.GetRoomManager().RemoveAllRooms(); AppendTimeStampWithComment(ref builder, RoomRemove, "Room destructor"); var DbSave = DateTime.Now; AppendTimeStampWithComment(ref builder, DbSave, "Database pre-save"); var connectionShutdown = DateTime.Now; ConnectionManager.Destroy(); AppendTimeStampWithComment(ref builder, connectionShutdown, "Connection shutdown"); var gameDestroy = DateTime.Now; Game.Destroy(); AppendTimeStampWithComment(ref builder, gameDestroy, "Game destroy"); var databaseDeconstructor = DateTime.Now; Console.WriteLine("[Otanix] @ Alerta: Finalizando o controle da database..."); manager.destroy(); Game.GetMuteManager().saveToDatabase(); AppendTimeStampWithComment(ref builder, databaseDeconstructor, "Database shutdown"); var timeUsedOnShutdown = DateTime.Now - ShutdownStart; builder.AppendLine("[Otanix] @ Alerta: Tempo total do processo de fechamento: " + TimeSpanToString(timeUsedOnShutdown)); builder.AppendLine(); Logging.LogShutdown(builder); Console.WriteLine("[Otanix] @ Alerta: Sistema completamente fechado, até a proxima!"); Environment.Exit(Environment.ExitCode); }
public static void PreformShutDown(bool ExitWhenDone) { StringBuilder builder = new StringBuilder(); DateTime now1 = DateTime.Now; DateTime now2 = DateTime.Now; ServerPacket message = new ServerPacket(ServerPacketHeader.BroadcastMessageAlertMessageComposer); message.WriteString("L'hôtel subit un redémarrage d'entretien, nous revenons dans quelques instants, nous nous excusons pour la gêne occasionnée !"); GetGame().GetClientManager().SendMessage(message); Thread.Sleep(10000); AppendTimeStampWithComment(ref builder, now2, "Hotel pre-warning"); _game.StopGameLoop(); Console.Write("Game loop stopped"); DateTime now3 = DateTime.Now; Console.WriteLine("Server shutting down..."); Console.Title = "<<- SERVER SHUTDOWN ->>"; GetConnectionManager().Destroy(); AppendTimeStampWithComment(ref builder, now3, "Socket close"); DateTime now5 = DateTime.Now; Console.WriteLine("<<- SERVER SHUTDOWN ->> ROOM SAVE"); _game.GetRoomManager().RemoveAllRooms(); AppendTimeStampWithComment(ref builder, now5, "Room destructor"); DateTime now4 = DateTime.Now; GetGame().GetClientManager().CloseAll(); AppendTimeStampWithComment(ref builder, now4, "Furni pre-save and connection close"); //ButterflyEnvironment.Game.GetPromotedRooms().executeUpdates(); DateTime now7 = DateTime.Now; if (_connectionManager != null) { _connectionManager.Destroy(); } if (_webSocketManager != null) { _webSocketManager.Destroy(); } AppendTimeStampWithComment(ref builder, now7, "Connection shutdown"); DateTime now8 = DateTime.Now; _game.Destroy(); AppendTimeStampWithComment(ref builder, now8, "Game destroy"); DateTime now9 = DateTime.Now; TimeSpan span = DateTime.Now - now1; builder.AppendLine("Total time on shutdown " + TimeSpanToString(span)); builder.AppendLine("You have reached ==> [END OF SESSION]"); builder.AppendLine(); builder.AppendLine(); builder.AppendLine(); Logging.LogShutdown(builder); Console.WriteLine("System disposed, goodbye!"); if (!ExitWhenDone) { return; } Environment.Exit(Environment.ExitCode); }
internal static void PreformShutDown(bool ExitWhenDone) { if (ShutdownInitiated || !isLive) { return; } StringBuilder builder = new StringBuilder(); DateTime ShutdownStart = DateTime.Now; DateTime MessaMessage = DateTime.Now; ShutdownInitiated = true; SendMassMessage(LanguageLocale.GetValue("shutdown.alert")); AppendTimeStampWithComment(ref builder, MessaMessage, "Hotel pre-warning"); Game.StopGameLoop(); Console.Write("Game loop stopped"); DateTime ConnectionClose = DateTime.Now; Console.WriteLine("Server shutting down..."); Console.Title = "<<- SERVER SHUTDOWN ->>"; GetConnectionManager().Destroy(); AppendTimeStampWithComment(ref builder, ConnectionClose, "Socket close"); DateTime sConnectionClose = DateTime.Now; GetGame().GetClientManager().CloseAll(); AppendTimeStampWithComment(ref builder, sConnectionClose, "Furni pre-save and connection close"); DateTime RoomRemove = DateTime.Now; Console.WriteLine("<<- SERVER SHUTDOWN ->> ROOM SAVE"); Game.GetRoomManager().RemoveAllRooms(); AppendTimeStampWithComment(ref builder, RoomRemove, "Room destructor"); DateTime DbSave = DateTime.Now; using (IQueryAdapter dbClient = manager.getQueryreactor()) { // dbClient.runFastQuery("TRUNCATE TABLE user_tickets"); dbClient.runFastQuery("TRUNCATE TABLE user_online"); dbClient.runFastQuery("TRUNCATE TABLE room_active"); //dbClient.runFastQuery("UPDATE users SET online = 0"); //dbClient.runFastQuery("UPDATE rooms SET users_now = 0"); } AppendTimeStampWithComment(ref builder, DbSave, "Database pre-save"); DateTime connectionShutdown = DateTime.Now; ConnectionManager.Destroy(); AppendTimeStampWithComment(ref builder, connectionShutdown, "Connection shutdown"); DateTime gameDestroy = DateTime.Now; Game.Destroy(); AppendTimeStampWithComment(ref builder, gameDestroy, "Game destroy"); DateTime databaseDeconstructor = DateTime.Now; try { Console.WriteLine("Destroying database manager."); manager.destroy(); } catch { } AppendTimeStampWithComment(ref builder, databaseDeconstructor, "Database shutdown"); TimeSpan timeUsedOnShutdown = DateTime.Now - ShutdownStart; builder.AppendLine("Total time on shutdown " + TimeSpanToString(timeUsedOnShutdown)); builder.AppendLine("You have reached ==> [END OF SESSION]"); builder.AppendLine(); builder.AppendLine(); builder.AppendLine(); Logging.LogShutdown(builder); Console.WriteLine("System disposed, goodbye!"); if (ExitWhenDone) { Environment.Exit(Environment.ExitCode); } }