/// <summary>
        /// Start the service, and stop the service if there were any errors found.
        /// </summary>
        /// <param name="Arguments">Command line arguments (unused).</param>
        protected override void OnStart(string[] Arguments)
        {
            // Create a log file for any start-up messages
            Log = new LogWriter("CrashReportProcess", LogFolder);

            Config.LoadConfig();

            Slack = new SlackWriter
            {
                WebhookUrl = Config.Default.SlackWebhookUrl,
                Channel    = Config.Default.SlackChannel,
                Username   = Config.Default.SlackUsername,
                IconEmoji  = Config.Default.SlackEmoji
            };

            StatusReporter = new StatusReporting();

            // Add directory watchers
            Watcher = new ReportWatcher();

            for (int ProcessorIndex = 0; ProcessorIndex < Config.Default.ProcessorThreadCount; ProcessorIndex++)
            {
                var Processor = new ReportProcessor(Watcher, ProcessorIndex);
                Processors.Add(Processor);
            }

            StatusReporter.Start();
            DateTime StartupTime = DateTime.UtcNow;

            WriteEvent("Successfully started at " + StartupTime);
        }
Exemplo n.º 2
0
        private static void TickStatic(ReportWatcher InWatcher)
        {
            if (Monitor.TryEnter(TickStaticLock, 0))
            {
                try
                {
                    // Remove all folders older than n days to prevent unbounded growth
                    if ((DateTime.Now - LastCleanupTime) > TimeSpan.FromMinutes(15))
                    {
                        CleanRepository(InWatcher);
                        LastCleanupTime = DateTime.Now;
                    }

                    DateTime CurrentDate = DateTime.UtcNow.Date;
                    if (CurrentDate > LoggingDate)
                    {
                        // Check the log and create a new one for a new day.
                        CrashReporterProcessServicer.Log.CreateNewLogFile();
                        LoggingDate = CurrentDate;
                    }
                }
                finally
                {
                    Monitor.Exit(TickStaticLock);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Stop the service.
        /// </summary>
        protected override void OnStop()
        {
            StatusReporter.OnPreStopping();

            // Clean up the directory watcher and crash processor threads
            foreach (var Processor in Processors)
            {
                Processor.RequestStop();
            }
            foreach (var Processor in Processors)
            {
                Processor.Dispose();
            }
            Processors.Clear();

            Watcher.Dispose();
            Watcher = null;

            StatusReporter.Dispose();
            StatusReporter = null;

            Slack.Dispose();
            Slack = null;

            // Flush the log to disk
            Log.Dispose();
            Log = null;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Global initialisation of the processor.
 /// </summary>
 /// <param name="InWatcher">The object that watches for new crash reports coming in.</param>
 public ReportProcessor(ReportWatcher InWatcher)
 {
     // Create the thread to handle processing
     Watcher      = InWatcher;
     CancelSource = new CancellationTokenSource();
     ProcessNewReports();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Global initialization of the processor.
 /// </summary>
 /// <param name="InWatcher">The object that watches for new crash reports coming in.</param>
 /// <param name="InProcessorIndex">The index of this processor in the application's thread list</param>
 public ReportProcessor(ReportWatcher InWatcher, int InProcessorIndex)
 {
     // Create the thread to handle processing
     Watcher        = InWatcher;
     ProcessorIndex = InProcessorIndex;
     CancelSource   = new CancellationTokenSource();
     Init();
 }
		/// <summary>
		/// Global initialization of the processor.
		/// </summary>
		/// <param name="InWatcher">The object that watches for new crash reports coming in.</param>
		/// <param name="InProcessorIndex">The index of this processor in the application's thread list</param>
		public ReportProcessor( ReportWatcher InWatcher, int InProcessorIndex )
		{
			// Create the thread to handle processing
			Watcher = InWatcher;
			ProcessorIndex = InProcessorIndex;
			CancelSource = new CancellationTokenSource();
			Init();
		}
        /// <summary>
        /// Start the service, and stop the service if there were any errors found.
        /// </summary>
        /// <param name="Arguments">Command line arguments (unused).</param>
        protected override void OnStart(string[] Arguments)
        {
            // Create a log file for any start-up messages
            Log = new CrashReportCommon.LogWriter("CrashReportProcess", LogFolder);

            // Add directory watchers
            Watcher = new ReportWatcher();

            Processor = new ReportProcessor(Watcher);

            WriteEvent("Successfully started at " + DateTime.Now.ToString());
        }
        private void OnDispose()
        {
            bDisposing = true;

            // Clean up the directory watcher and crash processor threads
            WriteEvent("Shutdown: Stopping ReportProcessors...");
            foreach (var Processor in Processors)
            {
                Processor.RequestStop();
            }
            WriteEvent("Shutdown: Disposing ReportProcessors...");
            foreach (var Processor in Processors)
            {
                Processor.Dispose();
            }
            Processors.Clear();
            WriteEvent("Shutdown: ReportProcessors stopped and disposed.");

            WriteEvent("Shutdown: Disposing ReportWatcher...");
            Watcher.Dispose();
            Watcher = null;
            WriteEvent("Shutdown: ReportWatcher disposed.");

            WriteEvent("Shutdown: Writing ReportIndex.");
            ReportIndex.WriteToFile();
            ReportIndex = null;
            WriteEvent("Shutdown: ReportIndex written.");

            WriteEvent("Shutdown: Disposing AmazonClients...");
            OutputAWS.Dispose();
            OutputAWS = null;
            DataRouterAWS.Dispose();
            DataRouterAWS = null;
            WriteEvent("Shutdown: AmazonClients disposed.");

            WriteEvent("Shutdown: Disposing StatusReporter...");
            StatusReporter.Dispose();
            StatusReporter = null;
            WriteEvent("Shutdown: StatusReporter disposed.");

            WriteEvent("Shutdown: Disposing SlackWriter...");
            Slack.Dispose();
            Slack = null;
            WriteEvent("Shutdown: SlackWriter disposed.");

            // Flush the log to disk
            WriteEvent("Shutdown: Disposing LogWriter.");
            Log.Dispose();
            Log = null;

            bDisposed = true;
        }
        /// <summary>
        /// Stop the service.
        /// </summary>
        protected override void OnStop()
        {
            // Clean up the directory watcher and crash processor threads
            Processor.Dispose();
            Processor = null;

            Watcher.Dispose();
            Watcher = null;

            // Flush the log to disk
            Log.Dispose();
            Log = null;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Delete report folders older than a certain age to avoid unbounded growth of the crash repository.
        /// </summary>
        /// <remarks>The folders for the deduplication process older than the property 'DeleteWaitingReportsDays' days old are deleted.</remarks>
        private static void CleanRepository(ReportWatcher InWatcher)
        {
            try
            {
                foreach (var Queue in InWatcher.ReportQueues)
                {
                    Queue.CleanLandingZone();
                }

                CrashReporterProcessServicer.Log.CleanOutOldLogs(Config.Default.DeleteWaitingReportsDays);
            }
            catch (Exception Ex)
            {
                CrashReporterProcessServicer.WriteException("CleanRepository: " + Ex, Ex);
            }
        }
        private void OnDispose()
        {
            bDisposing = true;

            // Clean up the directory watcher and crash processor threads
            foreach (var Processor in Processors)
            {
                Processor.RequestStop();
            }
            foreach (var Processor in Processors)
            {
                Processor.Dispose();
            }
            Processors.Clear();

            Watcher.Dispose();
            Watcher = null;

            ReportIndex.WriteToFile();
            ReportIndex = null;

            OutputAWS.Dispose();
            OutputAWS = null;

            DataRouterAWS.Dispose();
            DataRouterAWS = null;

            StatusReporter.Dispose();
            StatusReporter = null;

            Slack.Dispose();
            Slack = null;

            // Flush the log to disk
            Log.Dispose();
            Log = null;

            bDisposed = true;
        }
		/// <summary>
		/// Start the service, and stop the service if there were any errors found.
		/// </summary>
		/// <param name="Arguments">Command line arguments (unused).</param>
		protected override void OnStart( string[] Arguments )
		{
			// Create a log file for any start-up messages
			Log = new LogWriter("CrashReportProcess", LogFolder);

			Config.LoadConfig();

			Slack = new SlackWriter
			{
				WebhookUrl = Config.Default.SlackWebhookUrl,
				Channel = Config.Default.SlackChannel,
				Username = Config.Default.SlackUsername,
				IconEmoji = Config.Default.SlackEmoji
			};

			Symbolicator = new Symbolicator();

			StatusReporter = new StatusReporting();

			// Add directory watchers
			WriteEvent("Creating ReportWatcher");
			Watcher = new ReportWatcher();

			WriteEvent("Creating ReportProcessors");
			for (int ProcessorIndex = 0; ProcessorIndex < Config.Default.ProcessorThreadCount; ProcessorIndex++)
			{
				var Processor = new ReportProcessor(Watcher, ProcessorIndex);
				Processors.Add(Processor);
			}

			// Init events by enumerating event names
			WriteEvent("Initializing Event Counters");
			FieldInfo[] EventNameFields = typeof(StatusReportingEventNames).GetFields(BindingFlags.Static | BindingFlags.Public);
			StatusReporter.InitCounters(EventNameFields.Select(EventNameField => (string)EventNameField.GetValue(null)));

			WriteEvent("Initializing Folder Monitors");
			Dictionary<string, string> FoldersToMonitor = new Dictionary<string, string>();
			FoldersToMonitor.Add(Config.Default.ProcessedReports, "Processed Reports");
			FoldersToMonitor.Add(Config.Default.ProcessedVideos, "Processed Videos");
			FoldersToMonitor.Add(Config.Default.DepotRoot, "P4 Workspace");
			FoldersToMonitor.Add(Config.Default.InternalLandingZone, "CRR Landing Zone");
			FoldersToMonitor.Add(Config.Default.DataRouterLandingZone, "Data Router Landing Zone");
			FoldersToMonitor.Add(Config.Default.InvalidReportsDirectory, "Invalid Reports");
			FoldersToMonitor.Add(Assembly.GetExecutingAssembly().Location, "CRP Binaries and Logs");
			FoldersToMonitor.Add(Config.Default.MDDPDBCachePath, "MDD PDB Cache");
			StatusReporter.InitFolderMonitors(FoldersToMonitor);

			WriteEvent("Starting StatusReporter");
			StatusReporter.Start();

			// Start the threads now
			Watcher.Start();
			foreach (var Processor in Processors)
			{
				Processor.Start();
			}

			DateTime StartupTime = DateTime.UtcNow;
			WriteEvent("Successfully started at " + StartupTime);
		}
        /// <summary>
        /// Start the service, and stop the service if there were any errors found.
        /// </summary>
        /// <param name="Arguments">Command line arguments (unused).</param>
        protected override void OnStart(string[] Arguments)
        {
            // Create a log file for any start-up messages
            Log = new LogWriter("CrashReportProcess", LogFolder);

            Config.LoadConfig();

            Slack = new SlackWriter
            {
                WebhookUrl = Config.Default.SlackWebhookUrl,
                Channel    = Config.Default.SlackChannel,
                Username   = Config.Default.SlackUsername,
                IconEmoji  = Config.Default.SlackEmoji
            };

            Symbolicator = new Symbolicator();

            StatusReporter = new StatusReporting();

            ReportIndex = new ReportIndex
            {
                IsEnabled = !string.IsNullOrWhiteSpace(Config.Default.ProcessedReportsIndexPath),
                Filepath  = Config.Default.ProcessedReportsIndexPath,
                Retention = TimeSpan.FromDays(Config.Default.ReportsIndexRetentionDays)
            };

            ReportIndex.ReadFromFile();

            WriteEvent("Initializing AWS");
            string          AWSError;
            AWSCredentials  AWSCredentialsForDataRouter = new StoredProfileAWSCredentials(Config.Default.AWSProfileInputName, Config.Default.AWSCredentialsFilepath);
            AmazonSQSConfig SqsConfigForDataRouter      = new AmazonSQSConfig
            {
                ServiceURL = Config.Default.AWSSQSServiceInputURL
            };
            AmazonS3Config S3ConfigForDataRouter = new AmazonS3Config
            {
                ServiceURL = Config.Default.AWSS3ServiceInputURL
            };

            DataRouterAWS = new AmazonClient(AWSCredentialsForDataRouter, SqsConfigForDataRouter, S3ConfigForDataRouter, out AWSError);
            if (!DataRouterAWS.IsSQSValid || !DataRouterAWS.IsS3Valid)
            {
                WriteFailure("AWS failed to initialize profile for DataRouter access. Error:" + AWSError);
                StatusReporter.Alert("AWSFailInput", "AWS failed to initialize profile for DataRouter access", 0);
            }
            AWSCredentials AWSCredentialsForOutput = new StoredProfileAWSCredentials(Config.Default.AWSProfileOutputName, Config.Default.AWSCredentialsFilepath);
            AmazonS3Config S3ConfigForOutput       = new AmazonS3Config
            {
                ServiceURL = Config.Default.AWSS3ServiceOutputURL
            };

            OutputAWS = new AmazonClient(AWSCredentialsForOutput, null, S3ConfigForOutput, out AWSError);
            if (!OutputAWS.IsS3Valid)
            {
                WriteFailure("AWS failed to initialize profile for output S3 bucket access. Error:" + AWSError);
                StatusReporter.Alert("AWSFailOutput", "AWS failed to initialize profile for output S3 bucket access", 0);
            }

            // Add directory watchers
            WriteEvent("Creating ReportWatcher");
            Watcher = new ReportWatcher();

            WriteEvent("Creating ReportProcessors");
            for (int ProcessorIndex = 0; ProcessorIndex < Config.Default.ProcessorThreadCount; ProcessorIndex++)
            {
                var Processor = new ReportProcessor(Watcher, ProcessorIndex);
                Processors.Add(Processor);
            }

            // Init events by enumerating event names
            WriteEvent("Initializing Event Counters");
            FieldInfo[] EventNameFields = typeof(StatusReportingEventNames).GetFields(BindingFlags.Static | BindingFlags.Public);
            StatusReporter.InitCounters(EventNameFields.Select(EventNameField => (string)EventNameField.GetValue(null)));

            WriteEvent("Initializing Performance Mean Counters");
            FieldInfo[] MeanNameFields = typeof(StatusReportingPerfMeanNames).GetFields(BindingFlags.Static | BindingFlags.Public);
            StatusReporter.InitMeanCounters(MeanNameFields.Select(MeanNameField => (string)MeanNameField.GetValue(null)));

            WriteEvent("Initializing Folder Monitors");
            Dictionary <string, string> FoldersToMonitor = new Dictionary <string, string>();

            FoldersToMonitor.Add(Config.Default.ProcessedReports, "Processed Reports");
            FoldersToMonitor.Add(Config.Default.ProcessedVideos, "Processed Videos");
            FoldersToMonitor.Add(Config.Default.DepotRoot, "P4 Workspace");
            FoldersToMonitor.Add(Config.Default.InternalLandingZone, "CRR Landing Zone");
            FoldersToMonitor.Add(Config.Default.DataRouterLandingZone, "Data Router Landing Zone");
            FoldersToMonitor.Add(Config.Default.PS4LandingZone, "PS4 Landing Zone");
            FoldersToMonitor.Add(Assembly.GetExecutingAssembly().Location, "CRP Binaries and Logs");
            FoldersToMonitor.Add(Config.Default.MDDPDBCachePath, "MDD PDB Cache");
            StatusReporter.InitFolderMonitors(FoldersToMonitor);

            WriteEvent("Starting StatusReporter");
            StatusReporter.Start();

            // Start the threads now
            Watcher.Start();
            foreach (var Processor in Processors)
            {
                Processor.Start();
            }

            DateTime StartupTime = DateTime.UtcNow;

            WriteEvent("Successfully started at " + StartupTime);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Start the service, and stop the service if there were any errors found.
        /// </summary>
        /// <param name="Arguments">Command line arguments (unused).</param>
        protected override void OnStart(string[] Arguments)
        {
            // Create a log file for any start-up messages
            Log = new LogWriter("CrashReportProcess", LogFolder);

            Config.LoadConfig();

            Slack = new SlackWriter
            {
                WebhookUrl = Config.Default.SlackWebhookUrl,
                Channel    = Config.Default.SlackChannel,
                Username   = Config.Default.SlackUsername,
                IconEmoji  = Config.Default.SlackEmoji
            };

            Symbolicator = new Symbolicator();

            StatusReporter = new StatusReporting();

            // Add directory watchers
            WriteEvent("Creating ReportWatcher");
            Watcher = new ReportWatcher();

            WriteEvent("Creating ReportProcessors");
            for (int ProcessorIndex = 0; ProcessorIndex < Config.Default.ProcessorThreadCount; ProcessorIndex++)
            {
                var Processor = new ReportProcessor(Watcher, ProcessorIndex);
                Processors.Add(Processor);
            }

            // Init events by enumerating event names
            WriteEvent("Initializing Event Counters");
            FieldInfo[] EventNameFields = typeof(StatusReportingEventNames).GetFields(BindingFlags.Static | BindingFlags.Public);
            StatusReporter.InitCounters(EventNameFields.Select(EventNameField => (string)EventNameField.GetValue(null)));

            WriteEvent("Initializing Folder Monitors");
            Dictionary <string, string> FoldersToMonitor = new Dictionary <string, string>();

            FoldersToMonitor.Add(Config.Default.ProcessedReports, "Processed Reports");
            FoldersToMonitor.Add(Config.Default.ProcessedVideos, "Processed Videos");
            FoldersToMonitor.Add(Config.Default.DepotRoot, "P4 Workspace");
            FoldersToMonitor.Add(Config.Default.InternalLandingZone, "CRR Landing Zone");
            FoldersToMonitor.Add(Config.Default.DataRouterLandingZone, "Data Router Landing Zone");
            FoldersToMonitor.Add(Config.Default.InvalidReportsDirectory, "Invalid Reports");
            FoldersToMonitor.Add(Assembly.GetExecutingAssembly().Location, "CRP Binaries and Logs");
            FoldersToMonitor.Add(Config.Default.MDDPDBCachePath, "MDD PDB Cache");
            StatusReporter.InitFolderMonitors(FoldersToMonitor);

            WriteEvent("Starting StatusReporter");
            StatusReporter.Start();

            // Start the threads now
            Watcher.Start();
            foreach (var Processor in Processors)
            {
                Processor.Start();
            }

            DateTime StartupTime = DateTime.UtcNow;

            WriteEvent("Successfully started at " + StartupTime);
        }
Exemplo n.º 15
0
		/// <summary> 
		/// Delete report folders older than a certain age to avoid unbounded growth of the crash repository.
		/// </summary>
		/// <remarks>The folders for the deduplication process older than the property 'DeleteWaitingReportsDays' days old are deleted.</remarks>
		private static void CleanRepository(ReportWatcher InWatcher)
		{
			try
			{
				foreach (var Queue in InWatcher.ReportQueues)
				{
					Queue.CleanLandingZone();
				}

				CrashReporterProcessServicer.Log.CleanOutOldLogs(Config.Default.DeleteWaitingReportsDays);
			}
			catch( Exception Ex )
			{
				CrashReporterProcessServicer.WriteException( "CleanRepository: " + Ex.ToString() );
			}
		}
Exemplo n.º 16
0
		private static void TickStatic(ReportWatcher InWatcher)
		{
			if (Monitor.TryEnter(TickStaticLock, 0))
			{
				try
				{
					// Remove all folders older than n days to prevent unbounded growth
					if ((DateTime.Now - LastCleanupTime) > TimeSpan.FromMinutes(15))
					{
						CleanRepository(InWatcher);
						LastCleanupTime = DateTime.Now;
					}

					DateTime CurrentDate = DateTime.UtcNow.Date;
					if (CurrentDate > LoggingDate)
					{
						// Check the log and create a new one for a new day.
						CrashReporterProcessServicer.Log.CreateNewLogFile();
						LoggingDate = CurrentDate;
					}
				}
				finally
				{
					Monitor.Exit(TickStaticLock);
				}
			}
		}
		/// <summary>
		/// Stop the service.
		/// </summary>
		protected override void OnStop()
		{
			StatusReporter.OnPreStopping();

			// Clean up the directory watcher and crash processor threads
			foreach (var Processor in Processors)
			{
				Processor.RequestStop();
			}
			foreach (var Processor in Processors)
			{
				Processor.Dispose();
			}
			Processors.Clear();

			Watcher.Dispose();
			Watcher = null;

			StatusReporter.Dispose();
			StatusReporter = null;

			Slack.Dispose();
			Slack = null;

			// Flush the log to disk
			Log.Dispose();
			Log = null;
		}