/// <summary>
        /// The main method
        /// </summary>
        /// <param name="args">Command line arguments. These arguments are expected to be created by <see cref="IChildProcessManager.RunChildProcessAsync{TOutput}"/>.</param>
        /// <returns>Exit code</returns>
        public static int Main(string[] args)
        {
            IExtendedTracer tracer = null;

            try
            {
                // Inject dependencies
                container = DependenciesInjector.GetContainer()
                            .InjectAnalysisDependencies(withChildProcessRunner: false)
                            .WithChildProcessRegistrations(args);

                // Trace
                tracer = container.Resolve <IExtendedTracer>();
                tracer.TraceInformation($"Starting Smart Detector runner process, process ID {Process.GetCurrentProcess().Id}");

                // Run the analysis
                IChildProcessManager childProcessManager = container.Resolve <IChildProcessManager>();
                return(childProcessManager.RunAndListenToParentAsync <SmartDetectorExecutionRequest, List <ContractsAlert> >(args, RunSmartDetectorAsync, ConvertExceptionToExitCode).GetAwaiter().GetResult());
            }
            catch (Exception e)
            {
                tracer?.ReportException(e);
                tracer?.TraceError("Unhandled exception in child process: " + e.Message);
                Console.Error.WriteLine(e.ToString());
                return(-1);
            }
        }
コード例 #2
0
        /// <summary>
        /// The main method
        /// </summary>
        /// <param name="args">Command line arguments. These arguments are expected to be created by <see cref="IChildProcessManager.RunChildProcessAsync{TOutput}"/>.</param>
        /// <returns>Exit code</returns>
        public static int Main(string[] args)
        {
            ITracer tracer = null;

            try
            {
                // Inject dependencies
                container = DependenciesInjector.GetContainer()
                            .InjectAnalysisDependencies(withChildProcessRunner: false)
                            .WithChildProcessTracer(args);

                // Trace
                tracer = container.Resolve <ITracer>();
                tracer.TraceInformation($"Starting signal runner process, process ID {Process.GetCurrentProcess().Id}");

                // Run the analysis
                IChildProcessManager childProcessManager = container.Resolve <IChildProcessManager>();
                childProcessManager.RunAndListenToParentAsync <SmartSignalRequest, List <SmartSignalResultItemPresentation> >(args, RunSignalAsync).Wait();

                return(0);
            }
            catch (Exception e)
            {
                tracer?.TraceError("Unhandled exception in child process: " + e.Message);
                Console.Error.WriteLine(e.ToString());
                return(-1);
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes static members of the <see cref="Analyze"/> class.
        /// </summary>
        static Analyze()
        {
            // To increase Azure calls performance we increase default connection limit (default is 2) and ThreadPool minimum threads to allow more open connections
            ServicePointManager.DefaultConnectionLimit = 100;
            ThreadPool.SetMinThreads(100, 100);

            Container = DependenciesInjector.GetContainer()
                        .InjectAnalysisDependencies(withChildProcessRunner: true);
        }
コード例 #4
0
ファイル: SmartDetector.cs プロジェクト: lulzzz/Smart-Alerts
        /// <summary>
        /// Initializes static members of the <see cref="SmartDetector"/> class.
        /// </summary>
        static SmartDetector()
        {
            // To increase Azure calls performance we increase default connection limit (default is 2) and ThreadPool minimum threads to allow more open connections
            ServicePointManager.DefaultConnectionLimit = 100;
            ThreadPool.SetMinThreads(100, 100);

            Container = DependenciesInjector.GetContainer()
                        .RegisterType <ISmartDetectorApi, SmartDetectorApi>();
        }
コード例 #5
0
        /// <summary>
        /// Initializes static members of the <see cref="Resource"/> class.
        /// </summary>
        static Resource()
        {
            // To increase Azure calls performance we increase default connection limit (default is 2) and ThreadPool minimum threads to allow more open connections
            ServicePointManager.DefaultConnectionLimit = 100;
            ThreadPool.SetMinThreads(100, 100);

            Container = DependenciesInjector.GetContainer()
                        .RegisterType <IAuthorizationManagementClient, AuthorizationManagementClient>()
                        .RegisterType <IAzureResourceManagerClient, AzureResourceManagerClient>();
        }
コード例 #6
0
        static SmartDetector()
        {
            // To increase Azure calls performance we increase default connection limit (default is 2) and ThreadPool minimum threads to allow more open connections
            ServicePointManager.DefaultConnectionLimit = 100;
            ThreadPool.SetMinThreads(100, 100);

            // Force use the most updated TLS protocol
            SecurityProtocol.RemoveUnsecureProtocols();

            Container = DependenciesInjector.GetContainer()
                        .RegisterType <ISmartDetectorApi, SmartDetectorApi>();
        }
コード例 #7
0
        /// <summary>
        /// Initializes static members of the <see cref="SignalResult"/> class.
        /// </summary>
        static SignalResult()
        {
            // To increase Azure calls performance we increase default connection limit (default is 2) and ThreadPool minimum threads to allow more open connections
            ServicePointManager.DefaultConnectionLimit = 100;
            ThreadPool.SetMinThreads(100, 100);

            Container = DependenciesInjector.GetContainer()
                        .RegisterType <IAuthorizationManagementClient, AuthorizationManagementClient>()
                        .RegisterType <ICloudStorageProviderFactory, CloudStorageProviderFactory>()
                        .RegisterType <IApplicationInsightsClientFactory, ApplicationInsightsClientFactory>()
                        .RegisterType <ISignalResultApi, SignalResultApi>();
        }
コード例 #8
0
        static CheckResolution()
        {
            // To increase Azure calls performance we increase default connection limit (default is 2) and ThreadPool minimum threads to allow more open connections
            ServicePointManager.DefaultConnectionLimit = 100;
            ThreadPool.SetMinThreads(100, 100);

            // Force use the most updated TLS protocol
            SecurityProtocol.RemoveUnsecureProtocols();

            Container = DependenciesInjector.GetContainer()
                        .InjectAnalysisDependencies(withChildProcessRunner: true);
        }
コード例 #9
0
        /// <summary>
        /// Initializes static members of the <see cref="Schedule"/> class.
        /// </summary>
        static Schedule()
        {
            // To increase Azure calls performance we increase default connection limit (default is 2) and ThreadPool minimum threads to allow more open connections
            System.Net.ServicePointManager.DefaultConnectionLimit = 100;
            ThreadPool.SetMinThreads(100, 100);

            Container = DependenciesInjector.GetContainer()
                        .RegisterType <IAlertRuleStore, AlertRuleStore>()
                        .RegisterType <ISignalRunsTracker, SignalRunsTracker>()
                        .RegisterType <IAnalysisExecuter, AnalysisExecuter>()
                        .RegisterType <ISmartSignalResultPublisher, SmartSignalResultPublisher>()
                        .RegisterType <IEmailSender, EmailSender>();
        }