private void _WebControl_Crashed(object sender, CrashedEventArgs e)
        {
            if ((WebCore.IsShuttingDown) || (!WebCore.IsInitialized))
                return;

            Crashed?.Invoke(this, new BrowserCrashedArgs());
        }
Beispiel #2
0
 public static void EventSink_Crashed(CrashedEventArgs e)
 {
     try
     {
         World.Broadcast(0x35, true, "The server has crashed.");
     }
     catch
     {
     }
 }
Beispiel #3
0
		public static void EventSink_Crashed( CrashedEventArgs e )
		{
			try
			{
			    World.Broadcast(0x35, true, "The server has crashed, attempting to restart automatically...");
            }
			catch
			{
			}
		}
Beispiel #4
0
        public static void CrashGuard_OnCrash(CrashedEventArgs e)
        {
            if (GenerateReport)
                GenerateCrashReport(e);

            World.WaitForWriteCompletion();

            if (SaveBackup)
                Backup();

            /*if ( Core.Service )
            e.Close = true;
            else */ if (RestartServer)
                Restart(e);
        }
Beispiel #5
0
        public static void CrashGuard_OnCrash( CrashedEventArgs e )
        {
            if ( GenerateReport )
                GenerateCrashReport( e );

            World.Instance.WaitForWriteCompletion();

            if ( SaveBackup )
                Backup();

            if ( ShutdownServer )
                Shutdown();

            if ( RestartServer )
                Restart( e );
        }
Beispiel #6
0
		private static void Restart( CrashedEventArgs e )
		{
			Console.Write( "Crash: Restarting..." );

			try
			{
				Process.Start( Core.ExePath, Core.Arguments );
				Console.WriteLine( "done" );

				e.Close = true;
                //Core.Process.Kill(); //Taran: Tested a fix for server not shutting down properly on crash, but seemed to prohibit finishing crashlog etc.
			}
			catch
			{
				Console.WriteLine( "failed" );
			}
		}
Beispiel #7
0
		private static void EventSink_Crashed( CrashedEventArgs e )
		{
			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 );
				}
			}
		}
Beispiel #8
0
        private static void Restart(CrashedEventArgs 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");
            }
        }
Beispiel #9
0
        public static void EventSink_Crashed(CrashedEventArgs e)
        {
            foreach (PokerGame game in GameBackup.PokerGames)
            {
                List<PokerPlayer> toRemove = game.Players.Players.Where(player => player.Mobile != null).ToList();

                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.");
                    if (player.RoundCurrency > 0)
                    {
                        player.Currency += player.RoundCurrency;
                        game.CommunityCurrency -= player.RoundCurrency;
                    }
                    game.RemovePlayer(player);
                }
            }
        }
Beispiel #10
0
        private static void EventSink_Crashed(CrashedEventArgs e)
        {
            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);
                }
            }
        }
Beispiel #11
0
        public static void CrashGuard_OnCrash(CrashedEventArgs e)
        {
            if (GenerateReport)
            {
                GenerateCrashReport(e);
            }

            World.WaitForWriteCompletion();

            if (SaveBackup)
            {
                Backup();
            }

            /*if ( Core.Service )
             * e.Close = true;
             * else */if (RestartServer)
            {
                Restart(e);
            }
        }
Beispiel #12
0
        private void Crashed(object sender, CrashedEventArgs e)
        {
            if ((WebCore.IsShuttingDown) || (!WebCore.IsInitialized) || (Application.Current == null))
            {
                return;
            }

            var dest = _CurrentWebControl.Source;
            var vm   = Binding.Root;

            LogCritical("WebView crashed trying recover");

            _IWebViewLifeCycleManager.Dispose(_CurrentWebControl);
            _CurrentWebControl.ConsoleMessage -= ConsoleMessage;
            _CurrentWebControl.Crashed        -= Crashed;
            _CurrentWebControl = null;

            Binding = null;

            WebCore.QueueWork(() => Navigate(dest, vm, JavascriptBindingMode.TwoWay));
        }
Beispiel #13
0
        public static void CrashGuard_OnCrash(CrashedEventArgs e)
        {
            if (SaveBackup)
            {
                Backup();
            }

            if (GenerateReport)
            {
                GenerateCrashReport(e);
            }

            if (Core.Service)
            {
                e.Close = true;
            }
            else if (RestartServer)
            {
                Restart(e);
            }
        }
        public static void HbCrashEvent(object sender, CrashedEventArgs e)
        {
            if (e.ShutdownImminent.Equals(true))
            {
                if (ConfigKey.HbSaverKey.Enabled())
                {
                    if (ConfigKey.HbSaverKey.Enabled())
                    {
                        if (!File.Exists("heartbeatsaver.exe"))
                        {
                            return;
                        }

                        //start the heartbeat saver
                        Process HeartbeatSaver = new Process();
                        HeartbeatSaver.StartInfo.FileName = "heartbeatsaver.exe";
                        HeartbeatSaver.Start();
                    }
                }
            }
        }
Beispiel #15
0
        public static void HbCrashEvent(object sender, CrashedEventArgs e)
        {
            if (e.ShutdownImminent.Equals(true))
            {
                if (ConfigKey.HbSaverKey.Enabled())
                {
                    if (ConfigKey.HbSaverKey.Enabled())
                    {
                        if (!File.Exists("heartbeatsaver.exe"))
                        {
                            Logger.Log(LogType.Warning, "heartbeatsaver.exe does not exist and failed to launch");
                            return;
                        }

                        //start the heartbeat saver
                        Process HeartbeatSaver = new Process();
                        HeartbeatSaver.StartInfo.FileName = "heartbeatsaver.exe";
                        HeartbeatSaver.Start();
                    }
                }
            }
        }
Beispiel #16
0
        private void Step_Crashed(object sender, CrashedEventArgs e)
        {
            var prevStateNumber = _current;

            _steps[prevStateNumber].Completed -= Step_Completed;
            _steps[prevStateNumber].Crashed   -= Step_Crashed;

            if (_current == 0)
            {
                Crashed(this, e);
                return;
            }

            _current--;

            IList <string> errors = null;

            while (_current >= 0 && !_steps[_current].StartIfInputConditionsAreRight(_model, out errors))
            {
                _current--;
            }

            if (_current == -1)
            {
                Crashed(this, new CrashedEventArgs {
                    Errors = errors
                });
                return;
            }

            //если дошли, то значит шаг запустился
            _steps[_current].Completed += Step_Completed;
            _steps[_current].Crashed   += Step_Crashed;

            StepChanged(this, new StepChangedEventArgs {
                Step = _current
            });
        }
Beispiel #17
0
        const int MinCrashReportInterval       = 61;           // minimum interval between submitting crash reports, in seconds


        public static void LogAndReportCrash([CanBeNull] string message, [CanBeNull] string assembly,
                                             [CanBeNull] Exception exception, bool shutdownImminent)
        {
            if (message == null)
            {
                message = "(null)";
            }
            if (assembly == null)
            {
                assembly = "(null)";
            }
            if (exception == null)
            {
                exception = new Exception("(null)");
            }

            Log(LogType.SeriousError, "{0}: {1}", message, exception);

            bool submitCrashReport = ConfigKey.SubmitCrashReports.Enabled();
            bool isCommon          = CheckForCommonErrors(exception);

            // ReSharper disable EmptyGeneralCatchClause
            try
            {
                var eventArgs = new CrashedEventArgs(message,
                                                     assembly,
                                                     exception,
                                                     submitCrashReport && !isCommon,
                                                     isCommon,
                                                     shutdownImminent);
                RaiseCrashedEvent(eventArgs);
                isCommon = eventArgs.IsCommonProblem;
            }
            catch { }
            // ReSharper restore EmptyGeneralCatchClause
        }
Beispiel #18
0
        public static void CrashGuard_OnCrash(CrashedEventArgs e)
        {
            if (GenerateReport)
            {
                GenerateCrashReport(e);
            }

            World.Instance.WaitForWriteCompletion();

            if (SaveBackup)
            {
                Backup();
            }

            if (ShutdownServer)
            {
                Shutdown();
            }

            if (RestartServer)
            {
                Restart(e);
            }
        }
Beispiel #19
0
        public static void HandleCrashed( Exception e )
        {
            Console.WriteLine( "Error:" );
            Console.WriteLine( e );

            m_Crashed = true;

            bool close = false;

            try
            {
                CrashedEventArgs args = new CrashedEventArgs( e );

                EventSink.Instance.InvokeCrashed( args );

                close = args.Close;
            }
            catch
            {
            }

            if ( !close && !Environment.Service )
            {
                Console.WriteLine( "This exception is fatal, press return to exit" );
                Console.ReadLine();
            }

            m_Closing = true;
        }
Beispiel #20
0
        static void RaiseCrashedEvent(CrashedEventArgs e)
        {
            var h = Crashed;

            h?.Invoke(null, e);
        }
Beispiel #21
0
 private void OnCrashed(object sender, CrashedEventArgs e)
 {
     webControl.Reload(true);
 }
Beispiel #22
0
 static void aweView_Crashed(object sender, CrashedEventArgs e)
 {
     //throw new NotImplementedException();
 }
        private void Crashed(object sender, CrashedEventArgs e)
        {
            if ((WebCore.IsShuttingDown) || (!WebCore.IsInitialized) || (Application.Current==null))
                return;

            var dest = _CurrentWebControl.Source;
            var vm = Binding.Root;

            LogCritical("WebView crashed trying recover");
   
            _IWebViewLifeCycleManager.Dispose(_CurrentWebControl);
            _CurrentWebControl.ConsoleMessage -= ConsoleMessage;
            _CurrentWebControl.Crashed -= Crashed;
            _CurrentWebControl = null;

            Binding = null;

            WebCore.QueueWork(() => Navigate(dest, vm, JavascriptBindingMode.TwoWay));
        }
Beispiel #24
0
 private static void GenerateCrashReport(CrashedEventArgs e)
 {
     GenerateCrashReport(e.Exception);
 }
 private void OnCrashed(object sender, CrashedEventArgs e)
 {
     Debug.Print("Crashed! Status: " + e.Status);
 }
Beispiel #26
0
 private static void CatchCrash(CrashedEventArgs e)
 {
     SaveToFile();
 }
Beispiel #27
0
        private static void GenerateCrashReport(CrashedEventArgs e)
        {
            Console.Write("Crash: Generating report...");

            try
            {
                string fileName = String.Format("{0}.log", Directories.Now);

                string rootCrash = Directories.AppendPath(Directories.errors, "Crashes");
                string filePath  = Path.Combine(rootCrash, fileName);

                using (StreamWriter op = new StreamWriter(filePath))
                {
                    Version ver = Core.Assembly.GetName().Version;

                    op.WriteLine("Server Crash Report");
                    op.WriteLine("===================");
                    op.WriteLine();
                    op.WriteLine("RunUO Version {0}.{1}.{3}, Build {2}", ver.Major, ver.Minor, ver.Revision, ver.Build);
                    op.WriteLine("Operating System: {0}", Environment.OSVersion);
                    op.WriteLine(".NET Framework: {0}", Environment.Version);
                    op.WriteLine("Time: {0}", DateTime.Now);

                    try { op.WriteLine("Mobiles: {0}", World.Mobiles.Count); }
                    catch {}

                    try { op.WriteLine("Items: {0}", World.Items.Count); }
                    catch {}

                    op.WriteLine("Clients:");

                    try
                    {
                        List <NetState> states = NetState.Instances;

                        op.WriteLine("- Count: {0}", states.Count);

                        for (int i = 0; i < states.Count; ++i)
                        {
                            NetState state = (NetState)states[i];

                            op.Write("+ {0}:", state);

                            Account a = state.Account as Account;

                            if (a != null)
                            {
                                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");
                    }

                    op.WriteLine();

                    op.WriteLine("Exception:");
                    op.WriteLine(e.Exception);
                }

                Console.WriteLine("done");
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
Beispiel #28
0
    private void OnCrashed( object sender, CrashedEventArgs e )
    {
        if ( !webUI.IsLive || !webUI.IsDocumentReady )
            return;

        // Update the status text.
        webUI.ExecuteJavascript( "updateStatus('CRASHED!')" );
    }
Beispiel #29
0
 private void Awesomium_Windows_Forms_WebControl_Crashed(object sender, CrashedEventArgs e)
 {
     pbLoadingIndicator.Image = pbLoadingIndicator.ErrorImage;
     this.NewIntance();
 }
Beispiel #30
0
        private static void GenerateCrashReport(CrashedEventArgs e)
        {
            Console.Write("Crash: Generating report...");

            try
            {
                string timeStamp = GetTimeStamp();
                string fileName  = String.Format("Crash {0}.log", timeStamp);

                string root     = GetRoot();
                string filePath = Combine(root, fileName);

                using (StreamWriter op = new StreamWriter(filePath))
                {
                    op.WriteLine("Server Crash Report");
                    op.WriteLine("===================");
                    op.WriteLine();
                    op.WriteLine("Operating System: {0}", Environment.OSVersion);
                    op.WriteLine(".NET Framework: {0}", Environment.Version);
                    op.WriteLine("Time: {0}", DateTime.Now);

                    try { op.WriteLine("Mobiles: {0}", World.Mobiles.Count); }
                    catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

                    try { op.WriteLine("Items: {0}", World.Items.Count); }
                    catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

                    op.WriteLine("Clients:");

                    try
                    {
                        //ArrayList states = NetState.Instances;
                        List <NetState> states = NetState.Instances;

                        op.WriteLine("- Count: {0}", states.Count);

                        for (int i = 0; i < states.Count; ++i)
                        {
                            NetState state = states[i];

                            op.Write("+ {0}:", state);

                            Account a = state.Account as Account;

                            if (a != null)
                            {
                                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");
                    }

                    op.WriteLine();

                    op.WriteLine("Exception:");
                    op.WriteLine(e.Exception);
                }

                Console.WriteLine("done");

                // don't send email from some random developer's computer
                if (Emails != null && Utility.IsHostPrivate(Utility.GetHost()) == false)
                {
                    SendEmail(filePath);
                }
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
Beispiel #31
0
		private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
			var ex = e.ExceptionObject as Exception;
			ServerConsole.Write(EConsoleColor.Error, e.IsTerminating ? "Error: " : "Warning: ");
			ServerConsole.WriteLine(EConsoleColor.Error, Tools.CleanExcepionStacktrace(ex.Message));
			if (ex.StackTrace != string.Empty)
				ServerConsole.WriteLine(ex.StackTrace);

			if (e.IsTerminating == false) {
				return;
			}

			mCrashed = true;
			var close = false;
			try {
				var args = new CrashedEventArgs(e.ExceptionObject as Exception);
				Events.InvokeCrashed(args);
				close = args.Close;
			} catch (Exception) {
			}

			if (!close) {
				SocketPool.Destroy();

				ServerConsole.ErrorLine("This exception is fatal, press return to exit");
				ServerConsole.Read();
			}

			mClosing = true;
		}
 static void aweView_Crashed(object sender, CrashedEventArgs e)
 {
     //throw new NotImplementedException();
 }
Beispiel #33
0
 static void RaiseCrashedEvent( CrashedEventArgs e ) {
     var h = Crashed;
     if( h != null ) h( null, e );
 }
Beispiel #34
0
 public static void OnCrashed(CrashedEventArgs c)
 {
     try
     {
         SaveCommands();
     }
     catch
     {
     }
 }
Beispiel #35
0
 private void OnCrashed( object sender, CrashedEventArgs e )
 {
     Debug.Print( e.Status.ToString() );
 }
Beispiel #36
0
		public static void InvokeCrashed(CrashedEventArgs e) {
			if (Crashed != null)
				Crashed(e);
		}
Beispiel #37
0
        private static void GenerateCrashReport(CrashedEventArgs e)
        {
            Console.Write("Crash: Generating report...");

            try
            {
                string timeStamp = GetTimeStamp();
                string fileName  = String.Format("log/Crash {0}.log", timeStamp);

                string root     = GetRoot();
                string filePath = Combine(root, fileName);

                using (StreamWriter op = new StreamWriter(filePath))
                {
                    Version ver = Environment.Assembly.GetName().Version;

                    op.WriteLine("Server Crash Report");
                    op.WriteLine("===================");
                    op.WriteLine();
                    op.WriteLine("X-RunUO Version {0}.{1}.{2}, Build {3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
                    op.WriteLine("Operating System: {0}", System.Environment.OSVersion);
                    op.WriteLine(".NET Framework: {0}", System.Environment.Version);
                    op.WriteLine("Time: {0}", DateTime.Now);

                    try { op.WriteLine("Mobiles: {0}", World.Instance.MobileCount); }
                    catch { }

                    try { op.WriteLine("Items: {0}", World.Instance.ItemCount); }
                    catch { }

                    op.WriteLine("Exception:");
                    op.WriteLine(e.Exception);
                    op.WriteLine();

                    op.WriteLine("Clients:");

                    try
                    {
                        var server = GameServer.Instance;

                        op.WriteLine("- Count: {0}", server.ClientCount);

                        foreach (var client in server.Clients)
                        {
                            op.Write("+ {0}:", client);

                            Account a = client.Account as Account;

                            if (a != null)
                            {
                                op.Write(" (account = {0})", a.Username);
                            }

                            Mobile m = client.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");

                if (FromAddress != null && CrashAddresses != null)
                {
                    SendEmail(filePath);
                }
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
Beispiel #38
0
 private void OnCrashed(object sender, CrashedEventArgs e)
 {
     // Oops! The WebView crashed.
     Mogre.LogManager.Singleton.DefaultLog.LogMessage(e.Status.ToString());
 }
Beispiel #39
0
 private void Awesomium_Windows_Forms_WebControl_Crashed(object sender, CrashedEventArgs e)
 {
     this.labelNavigationStatus.Text("Browser crashed");
 }
Beispiel #40
0
        private static void GenerateCrashReport( CrashedEventArgs e )
        {
            Console.Write( "Crash: Generating report..." );

            try
            {
                string timeStamp = GetTimeStamp();
                string fileName = String.Format( "log/Crash {0}.log", timeStamp );

                string root = GetRoot();
                string filePath = Combine( root, fileName );

                using ( StreamWriter op = new StreamWriter( filePath ) )
                {
                    Version ver = Environment.Assembly.GetName().Version;

                    op.WriteLine( "Server Crash Report" );
                    op.WriteLine( "===================" );
                    op.WriteLine();
                    op.WriteLine( "X-RunUO Version {0}.{1}.{2}, Build {3}", ver.Major, ver.Minor, ver.Build, ver.Revision );
                    op.WriteLine( "Operating System: {0}", System.Environment.OSVersion );
                    op.WriteLine( ".NET Framework: {0}", System.Environment.Version );
                    op.WriteLine( "Time: {0}", DateTime.Now );

                    try { op.WriteLine( "Mobiles: {0}", World.Instance.MobileCount ); }
                    catch { }

                    try { op.WriteLine( "Items: {0}", World.Instance.ItemCount ); }
                    catch { }

                    op.WriteLine( "Exception:" );
                    op.WriteLine( e.Exception );
                    op.WriteLine();

                    op.WriteLine( "Clients:" );

                    try
                    {
                        var server = GameServer.Instance;

                        op.WriteLine( "- Count: {0}", server.ClientCount );

                        foreach ( var client in server.Clients )
                        {
                            op.Write( "+ {0}:", client );

                            Account a = client.Account as Account;

                            if ( a != null )
                                op.Write( " (account = {0})", a.Username );

                            Mobile m = client.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" );

                if ( FromAddress != null && CrashAddresses != null )
                    SendEmail( filePath );
            }
            catch
            {
                Console.WriteLine( "failed" );
            }
        }
Beispiel #41
0
        private static void GenerateCrashReport(CrashedEventArgs e)
        {
            Console.Write("Crash: Generating report...");

            try
            {
                string timeStamp = GetTimeStamp();
                string fileName = String.Format("Crash {0}.log", timeStamp);

                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("RunUO 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
                    {
                    }

                    try
                    {
                        op.WriteLine("Items: {0}", World.Items.Count);
                    }
                    catch
                    {
                    }

                    op.WriteLine("Exception:");
                    op.WriteLine(e.Exception);
                    op.WriteLine();

                    op.WriteLine("Clients:");

                    try
                    {
                        List<NetState> states = NetState.Instances;

                        op.WriteLine("- Count: {0}", states.Count);

                        for (int i = 0; i < states.Count; ++i)
                        {
                            NetState state = states[i];

                            op.Write("+ {0}:", state);

                            Account a = state.Account as Account;

                            if (a != null)
                                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");

                if (Email.FromAddress != null && Email.CrashAddresses != null)
                    SendEmail(filePath);
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
Beispiel #42
0
        public static void LogAndReportCrash([CanBeNull] string message, [CanBeNull] string assembly,
                                             [CanBeNull] Exception exception, bool shutdownImminent)
        {
            DateTime n    = DateTime.Now;
            string   file = $"crash{ReportDateTime(n)}";

            if (message == null)
            {
                message = "(null)";
            }
            if (assembly == null)
            {
                assembly = "(null)";
            }
            if (exception == null)
            {
                exception = new Exception("(null)");
            }

            Log(LogType.SeriousError, "{0}: {1}", message, exception);

            bool submitCrashReport = ConfigKey.SubmitCrashReports.Enabled();
            bool isCommon          = CheckForCommonErrors(exception);

            // ReSharper disable EmptyGeneralCatchClause
            try
            {
                var eventArgs = new CrashedEventArgs(message,
                                                     assembly,
                                                     exception,
                                                     submitCrashReport && !isCommon,
                                                     isCommon,
                                                     shutdownImminent);
                RaiseCrashedEvent(eventArgs);
                isCommon = eventArgs.IsCommonProblem;
            }
            catch { }
            // ReSharper restore EmptyGeneralCatchClause

            if (!submitCrashReport || isCommon)
            {
                return;
            }

            lock (CrashReportLock)
            {
                if (DateTime.UtcNow.Subtract(lastCrashReport).TotalSeconds < MinCrashReportInterval)
                {
                    Log(LogType.Warning, "Logger.SubmitCrashReport: Could not submit crash report, reports too frequent.");
                    return;
                }
                lastCrashReport = DateTime.UtcNow;

                try
                {
                    StringBuilder   sb   = new StringBuilder();
                    CrashReportData data = new CrashReportData
                    {
                        SoftwareVersion = Updater.LatestStable.ToString(),
                        Error           = message
                    };


                    if (MonoCompat.IsMono)
                    {
                        data.OperatingSystem = Environment.OSVersion.VersionString;
                        data.Runtime         = "Mono " + MonoCompat.MonoVersionString;
                    }
                    else
                    {
                        data.OperatingSystem = GetOS() + Environment.OSVersion.ServicePack;
                        data.Runtime         =
                            $".Net {".Net " + Environment.Version.Major + "." + Environment.Version.MajorRevision + "." + Environment.Version.Build}";
                    }
                    data.ServerName = ConfigKey.ServerName.GetString();


                    if (exception is TargetInvocationException)
                    {
                        exception = (exception).InnerException;
                    }
                    else if (exception is TypeInitializationException)
                    {
                        exception = (exception).InnerException;
                    }

                    if (exception != null)
                    {
                        data.Exception = exception.GetType() + ": " + exception.Message + ", Stack: " +
                                         exception.StackTrace;
                    }

                    data.Config = File.Exists(Paths.ConfigFileName) ? Paths.ConfigFileName : "config.json not found";

                    string[] lastFewLines;
                    lock (LogLock)
                    {
                        lastFewLines = RecentMessages.ToArray();
                    }

                    data.Logs = string.Join(Environment.NewLine, lastFewLines);
                    string json     = JsonConvert.SerializeObject(data, Formatting.Indented);
                    string postData = $"?json={Uri.EscapeDataString(json)}";
                    byte[] formData = Encoding.UTF8.GetBytes(postData);

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(CrashReportUri);
                    request.Method        = "POST";
                    request.Timeout       = 15000; // 15s timeout
                    request.ContentType   = "application/x-www-form-urlencoded";
                    request.CachePolicy   = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                    request.ContentLength = formData.Length;

                    using (Stream requestStream = request.GetRequestStream())
                    {
                        requestStream.Write(formData, 0, formData.Length);
                        requestStream.Flush();
                    }

                    string responseString;
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        using (Stream responseStream = response.GetResponseStream())
                        {
                            // ReSharper disable AssignNullToNotNullAttribute
                            using (StreamReader reader = new StreamReader(responseStream))
                            {
                                // ReSharper restore AssignNullToNotNullAttribute
                                responseString = reader.ReadLine();
                            }
                        }
                    }
                    request.Abort();

                    if (responseString != null && responseString.StartsWith("ERROR"))
                    {
                        Log(LogType.Error, "Crash report could not be processed by gemscraft.net.");
                    }
                    else
                    {
                        if (responseString != null && int.TryParse(responseString, out var referenceNumber))
                        {
                            Log(LogType.SystemActivity, "Crash report submitted (Reference #{0})", referenceNumber);
                        }
                        else
                        {
                            Log(LogType.SystemActivity, "Crash report submitted.");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log(LogType.Warning, "Logger.SubmitCrashReport: {0}", ex.Message);
                }
            }
        }
Beispiel #43
0
 private void OnCrashed(object sender, CrashedEventArgs e)
 {
     // Oops! The WebView crashed.
     Mogre.LogManager.Singleton.DefaultLog.LogMessage(e.Status.ToString());
 }
Beispiel #44
0
 private void OnCrashed(object sender, CrashedEventArgs e)
 {
     Debug.Print(e.Status.ToString());
 }
Beispiel #45
0
 private void Awesomium_Windows_Forms_WebControl_Crashed( object sender, CrashedEventArgs e ) {
     this.labelNavigationStatus.Text( "Browser crashed" );
 }
Beispiel #46
0
 private void OnCrashed(object sender, CrashedEventArgs e)
 {
     AddMessage(string.Format(Resource.MainForm_AwesomiumCrashed + e.Status));
     RestartApplication();
 }
Beispiel #47
0
        private static void OnServerCrashed(CrashedEventArgs e)
        {
            if (World.Loading || World.Saving)
            {
                return;
            }

            PokerGame.EventSink_Crashed(e);

            _Event = e;
            _Stamp = DateTime.Now;

            Core.CrashedHandler = null;

            VitaNexCore.TryCatch(
                () =>
            {
                if (CSOptions.Report)
                {
                    CSOptions.ToConsole("Writing Crash Report...");
                    CSOptions.ToConsole(Report() ? "Done" : "Failed");
                }

                //World.WaitForWriteCompletion();

                if (CSOptions.Backup)
                {
                    CSOptions.ToConsole("Backing Up Saves...");
                    CSOptions.ToConsole(Backup(false) ? "Done" : "Failed");
                }

                if (CSOptions.Restore)
                {
                    CSOptions.ToConsole("Creating Restore Saves...");
                    CSOptions.ToConsole(Backup(true) ? "Done" : "Failed");
                }

                Delta();

                if (!CSOptions.Restart)
                {
                    return;
                }

                if (CSOptions.RestartDelay > TimeSpan.Zero)
                {
                    CSOptions.ToConsole("Press 'ESC' to cancel or 'Enter' to skip the restart delay...");
                    CSOptions.ToConsole("{0} will restart in: ", ServerList.ServerName);

                    _RestartTime = (int)Math.Ceiling(CSOptions.RestartDelay.TotalSeconds);

                    int cX = Console.CursorLeft;
                    int cY = Console.CursorTop;

                    var wait = new EventWaitHandle(false, EventResetMode.ManualReset);

                    ThreadPool.QueueUserWorkItem(
                        cb =>
                    {
                        bool exit = false;

                        do
                        {
                            lock (VitaNexCore.ConsoleLock)
                            {
                                Console.CursorLeft = cX;
                                Console.CursorTop  = cY;
                                Console.Write(new String(' ', 40));
                                Console.CursorLeft = cX;
                                Console.CursorTop  = cY;
                                Console.Write("{0} second{1}", _RestartTime, _RestartTime != 1 ? "s" : String.Empty);
                            }

                            if (_RestartIntercept || _RestartForce)
                            {
                                exit = true;
                            }

                            if (_RestartTime-- < 0)
                            {
                                exit = _RestartForce = true;
                            }

                            if (!exit)
                            {
                                Thread.Sleep(1000);
                            }

                            wait.Set();
                        }while (!exit);
                    });

                    ThreadPool.QueueUserWorkItem(
                        cb =>
                    {
                        bool escape = false;

                        do
                        {
                            if (_RestartForce || _RestartIntercept || _RestartTime <= 0)
                            {
                                escape = true;
                            }

                            if (!escape && !Console.KeyAvailable)
                            {
                                switch (Console.ReadKey(true).Key)
                                {
                                case ConsoleKey.Escape:
                                    escape = _RestartForce = _RestartIntercept = true;
                                    break;

                                case ConsoleKey.Enter:
                                    escape = _RestartForce = true;
                                    break;
                                }
                            }

                            if (!escape)
                            {
                                wait.WaitOne();
                            }
                        }while (!escape);
                    });

                    while (!_RestartForce && !_RestartIntercept && _RestartTime > 0)
                    {
                        Thread.Sleep(10);
                    }

                    lock (VitaNexCore.ConsoleLock)
                    {
                        Console.WriteLine();
                    }
                }

                DeltaRestart();
            },
                CSOptions.ToConsole);
        }
Beispiel #48
0
        const int MinCrashReportInterval = 61; // minimum interval between submitting crash reports, in seconds


        public static void LogAndReportCrash( [CanBeNull] string message, [CanBeNull] string assembly,
                                              [CanBeNull] Exception exception, bool shutdownImminent ) {
            if( message == null ) message = "(null)";
            if( assembly == null ) assembly = "(null)";
            if( exception == null ) exception = new Exception( "(null)" );

            Log( LogType.SeriousError, "{0}: {1}", message, exception );

            bool submitCrashReport = ConfigKey.SubmitCrashReports.Enabled();
            bool isCommon = CheckForCommonErrors( exception );

            try {
                var eventArgs = new CrashedEventArgs( message,
                                                      assembly,
                                                      exception,
                                                      submitCrashReport && !isCommon,
                                                      isCommon,
                                                      shutdownImminent );
                RaiseCrashedEvent( eventArgs );
                isCommon = eventArgs.IsCommonProblem;
            } catch { }

            if( !submitCrashReport || isCommon ) {
                return;
            }

            lock( CrashReportLock ) {
                if( DateTime.UtcNow.Subtract( lastCrashReport ).TotalSeconds < MinCrashReportInterval ) {
                    Log( LogType.Warning, "Logger.SubmitCrashReport: Could not submit crash report, reports too frequent." );
                    return;
                }
                lastCrashReport = DateTime.UtcNow;

                try {
                    StringBuilder sb = new StringBuilder();
                    sb.Append( "version=" ).Append( Uri.EscapeDataString( Updater.CurrentRelease.VersionString ) );
                    sb.Append( "&message=" ).Append( Uri.EscapeDataString( message ) );
                    sb.Append( "&assembly=" ).Append( Uri.EscapeDataString( assembly ) );
                    sb.Append( "&runtime=" );
                    if( MonoCompat.IsMono ) {
                        sb.Append( Uri.EscapeDataString( "Mono " + MonoCompat.MonoVersionString ) );
                    } else {
                        sb.Append( Uri.EscapeDataString( "CLR " + Environment.Version ) );
                    }
                    sb.Append( "&os=" ).Append( Environment.OSVersion.Platform + " / " + Environment.OSVersion.VersionString );

                    if( exception is TargetInvocationException ) {
                        exception = (exception).InnerException;
                    } else if( exception is TypeInitializationException ) {
                        exception = (exception).InnerException;
                    }
                    sb.Append( "&exceptiontype=" ).Append( Uri.EscapeDataString( exception.GetType().ToString() ) );
                    sb.Append( "&exceptionmessage=" ).Append( Uri.EscapeDataString( exception.Message ) );
                    sb.Append( "&exceptionstacktrace=" ).Append( Uri.EscapeDataString( exception.StackTrace ) );

                    if( File.Exists( Paths.ConfigFileName ) ) {
                        sb.Append( "&config=" ).Append( Uri.EscapeDataString( File.ReadAllText( Paths.ConfigFileName ) ) );
                    } else {
                        sb.Append( "&config=" );
                    }

                    string[] lastFewLines;
                    lock( LogLock ) {
                        lastFewLines = RecentMessages.ToArray();
                    }
                    sb.Append( "&log=" ).Append( Uri.EscapeDataString( String.Join( Environment.NewLine, lastFewLines ) ) );

                    byte[] formData = Encoding.UTF8.GetBytes( sb.ToString() );

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create( CrashReportUri );
                    request.Method = "POST";
                    request.Timeout = 15000; // 15s timeout
                    request.ContentType = "application/x-www-form-urlencoded";
                    request.CachePolicy = new RequestCachePolicy( RequestCacheLevel.NoCacheNoStore );
                    request.ContentLength = formData.Length;
                    request.UserAgent = Updater.UserAgent;

                    using( Stream requestStream = request.GetRequestStream() ) {
                        requestStream.Write( formData, 0, formData.Length );
                        requestStream.Flush();
                    }

                    string responseString;
                    using( HttpWebResponse response = (HttpWebResponse)request.GetResponse() ) {
                        using( Stream responseStream = response.GetResponseStream() ) {
                            using( StreamReader reader = new StreamReader( responseStream ) ) {
                                responseString = reader.ReadLine();
                            }
                        }
                    }
                    request.Abort();

                    if( responseString != null && responseString.StartsWith( "ERROR" ) ) {
                        Log( LogType.Error, "Crash report could not be processed by fCraft.net." );
                    } else {
                        int referenceNumber;
                        if( responseString != null && Int32.TryParse( responseString, out referenceNumber ) ) {
                            Log( LogType.SystemActivity, "Crash report submitted (Reference #{0})", referenceNumber );
                        } else {
                            Log( LogType.SystemActivity, "Crash report submitted." );
                        }
                    }


                } catch( Exception ex ) {
                    Log( LogType.Warning, "Logger.SubmitCrashReport: {0}", ex.Message );
                }
            }
        }
Beispiel #49
0
 void webControlDetails_Crashed(object sender, CrashedEventArgs e)
 {
     throw new Exception("Awesomium crashed\r\n" + e.ToString());
 }
        private static void GenerateCrashReport(CrashedEventArgs e)
        {
            Console.Write("Crash: Generating report...");

            try
            {
                string timeStamp = GetTimeStamp();
                string fileName  = String.Format("Crash {0}.log", timeStamp);

                #region ForcedServerCrash [01-01]

                if (ForceServerCrash.CrashServer)
                {
                    fileName = "Forced " + fileName;
                }

                #endregion

                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("RunUO 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 { }

                    try { op.WriteLine("Items: {0}", World.Items.Count); }
                    catch { }

                    op.WriteLine("Exception:");
                    op.WriteLine(e.Exception);
                    op.WriteLine();

                    op.WriteLine("Clients:");

                    try
                    {
                        List <NetState> states = NetState.Instances;

                        op.WriteLine("- Count: {0}", states.Count);

                        for (int i = 0; i < states.Count; ++i)
                        {
                            NetState state = states[i];

                            op.Write("+ {0}:", state);

                            Account a = state.Account as Account;

                            if (a != null)
                            {
                                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");

                if (Email.FromAddress != null && Email.CrashAddresses != null)
                {
                    SendEmail(filePath);
                }
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
Beispiel #51
0
        internal void webView_Crashed(object sender, CrashedEventArgs e)
        {
            Error getLastError = webView.GetLastError();

            throw new Exception("WebKit Error :" + getLastError.ToString());
        }