Beispiel #1
0
        private static void BackgroundJobsPostStart(IAppConfiguration configuration)
        {
            var indexer = Container.Kernel.TryGet <IIndexingService>();
            var jobs    = new List <IJob>();

            if (indexer != null)
            {
                indexer.RegisterBackgroundJobs(jobs, configuration);
            }
            if (!configuration.HasWorker)
            {
                jobs.Add(
                    new UpdateStatisticsJob(TimeSpan.FromMinutes(5),
                                            () => new EntitiesContext(configuration.SqlConnectionString, readOnly: false),
                                            timeout: TimeSpan.FromMinutes(5)));
            }
            if (configuration.CollectPerfLogs)
            {
                jobs.Add(CreateLogFlushJob());
            }

            if (jobs.AnySafe())
            {
                var jobCoordinator = new NuGetJobCoordinator();
                _jobManager = new JobManager(jobs, jobCoordinator)
                {
                    RestartSchedulerOnFailure = true
                };
                _jobManager.Fail(e => ErrorLog.GetDefault(null).Log(new Error(e)));
                _jobManager.Start();
            }
        }
        private static void BackgroundJobsPostStart(IAppConfiguration configuration)
        {
            var indexingJobFactory = DependencyResolver.Current.GetService <IIndexingJobFactory>();
            var jobs = new List <IJob>();

            if (indexingJobFactory != null)
            {
                indexingJobFactory.RegisterBackgroundJobs(jobs, configuration);
            }

            if (configuration.StorageType == StorageType.AzureStorage)
            {
                var cloudDownloadCountService = DependencyResolver.Current.GetService <IDownloadCountService>() as CloudDownloadCountService;
                if (cloudDownloadCountService != null)
                {
                    // Perform initial refresh + schedule new refreshes every 15 minutes
                    HostingEnvironment.QueueBackgroundWorkItem(_ => cloudDownloadCountService.RefreshAsync());
                    jobs.Add(new CloudDownloadCountServiceRefreshJob(TimeSpan.FromMinutes(15), cloudDownloadCountService));
                }
            }

            if (jobs.AnySafe())
            {
                var jobCoordinator = new NuGetJobCoordinator();
                _jobManager = new JobManager(jobs, jobCoordinator)
                {
                    RestartSchedulerOnFailure = true
                };
                _jobManager.Fail(e => ErrorLog.GetDefault(null).Log(new Error(e)));
                _jobManager.Start();
            }
        }
Beispiel #3
0
        private static void BackgroundJobsPostStart(IAppConfiguration configuration)
        {
            var indexer = DependencyResolver.Current.GetService <IIndexingService>();
            var jobs    = new List <IJob>();

            if (indexer != null)
            {
                indexer.RegisterBackgroundJobs(jobs, configuration);
            }
            if (!configuration.HasWorker)
            {
                jobs.Add(
                    new UpdateStatisticsJob(TimeSpan.FromMinutes(5),
                                            () => new EntitiesContext(configuration.SqlConnectionString, readOnly: false),
                                            timeout: TimeSpan.FromMinutes(5)));
            }
            if (configuration.CollectPerfLogs)
            {
                jobs.Add(CreateLogFlushJob());
            }

            if (configuration.StorageType == StorageType.AzureStorage)
            {
                var cloudDownloadCountService = DependencyResolver.Current.GetService <IDownloadCountService>() as CloudDownloadCountService;
                if (cloudDownloadCountService != null)
                {
                    // Perform initial refresh + schedule new refreshes every 15 minutes
                    HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => cloudDownloadCountService.Refresh());
                    jobs.Add(new CloudDownloadCountServiceRefreshJob(TimeSpan.FromMinutes(15), cloudDownloadCountService));
                }
            }

            if (jobs.AnySafe())
            {
                var jobCoordinator = new NuGetJobCoordinator();
                _jobManager = new JobManager(jobs, jobCoordinator)
                {
                    RestartSchedulerOnFailure = true
                };
                _jobManager.Fail(e => ErrorLog.GetDefault(null).Log(new Error(e)));
                _jobManager.Start();
            }
        }
        private static void BackgroundJobsPostStart(IAppConfiguration configuration)
        {
            var indexer = Container.Kernel.TryGet<IIndexingService>();
            var jobs = new List<IJob>();
            if (indexer != null)
            {
                indexer.RegisterBackgroundJobs(jobs, configuration);
            }
            if (!configuration.HasWorker)
            {
                jobs.Add(
                    new UpdateStatisticsJob(TimeSpan.FromMinutes(5), 
                        () => new EntitiesContext(configuration.SqlConnectionString, readOnly: false), 
                        timeout: TimeSpan.FromMinutes(5)));
            }
            if (configuration.CollectPerfLogs)
            {
                jobs.Add(CreateLogFlushJob());
            }

            if (jobs.AnySafe())
            {
                var jobCoordinator = new NuGetJobCoordinator();
                _jobManager = new JobManager(jobs, jobCoordinator)
                    {
                        RestartSchedulerOnFailure = true
                    };
                _jobManager.Fail(e => ErrorLog.GetDefault(null).Log(new Error(e)));
                _jobManager.Start();
            }
        }
Beispiel #5
0
        private static void BackgroundJobsPostStart(IAppConfiguration configuration)
        {
            var indexer = DependencyResolver.Current.GetService<IIndexingService>();
            var jobs = new List<IJob>();
            if (indexer != null)
            {
                indexer.RegisterBackgroundJobs(jobs, configuration);
            }
            if (!configuration.HasWorker)
            {
                jobs.Add(
                    new UpdateStatisticsJob(TimeSpan.FromMinutes(5),
                        () => new EntitiesContext(configuration.SqlConnectionString, readOnly: false),
                        timeout: TimeSpan.FromMinutes(5)));
            }
            if (configuration.CollectPerfLogs)
            {
                jobs.Add(CreateLogFlushJob());
            }

            if (configuration.StorageType == StorageType.AzureStorage)
            {
                var cloudDownloadCountService = DependencyResolver.Current.GetService<IDownloadCountService>() as CloudDownloadCountService;
                if (cloudDownloadCountService != null)
                {
                    // Perform initial refresh + schedule new refreshes every 15 minutes
                    HostingEnvironment.QueueBackgroundWorkItem(cancellationToken => cloudDownloadCountService.Refresh());
                    jobs.Add(new CloudDownloadCountServiceRefreshJob(TimeSpan.FromMinutes(15), cloudDownloadCountService));
                }
            }

            if (jobs.AnySafe())
            {
                var jobCoordinator = new NuGetJobCoordinator();
                _jobManager = new JobManager(jobs, jobCoordinator)
                    {
                        RestartSchedulerOnFailure = true
                    };
                _jobManager.Fail(e => ErrorLog.GetDefault(null).Log(new Error(e)));
                _jobManager.Start();
            }
        }