示例#1
0
        public static void Main() {
            var loggerFactory = new LoggerFactory();
            loggerFactory.AddNLog();
            loggerFactory.DefaultLogLevel = LogLevel.Trace;
            var logger = loggerFactory.CreateLogger<Program>();

            var serviceProvider = ServiceProvider.FindAndGetServiceProvider(typeof(EveryMinuteJob), loggerFactory);

            for (int i = 0; i < 5; i++) {
                Task.Run(() => {
                    var cronService = new CronService(serviceProvider.GetService<ICacheClient>(), loggerFactory);

                    // every minute
                    cronService.Add(serviceProvider.GetService<EveryMinuteJob>(), "* * * * *");

                    // every even minute
                    cronService.Add(() => serviceProvider.GetService<EvenMinuteJob>(), "*/2 * * * *");

                    logger.Info($"Cron Service ({i}) Running on {Thread.CurrentThread.ManagedThreadId}");
                    cronService.Run();
                });
            }

            Console.ReadKey();
        }
示例#2
0
        public static int Main() {
            var loggerFactory = new LoggerFactory();
            loggerFactory.AddNLog();
            loggerFactory.DefaultLogLevel = LogLevel.Trace;

            var serviceProvider = ServiceProvider.FindAndGetServiceProvider(typeof(PingQueueJob), loggerFactory);

            return TopshelfJob.Run<PingQueueJob>(() => serviceProvider.GetService<PingQueueJob>(), loggerFactory: loggerFactory);
        }
 private static void RunJobs(LoggerFactory loggerFactory) {
     var jobRunner = new JobRunner(loggerFactory);
     jobRunner.RunContinuousAsync<ValuesPostJob>();
     jobRunner.RunContinuousAsync<WorkItemJob>(instanceCount: 2);
 }
示例#4
0
        public static Container CreateContainer(LoggerFactory loggerFactory, ILogger logger, bool includeInsulation = true) {
            var container = new Container();
            container.Options.AllowOverridingRegistrations = true;
            container.Options.DefaultScopedLifestyle = new WebApiRequestLifestyle();

            Core.Bootstrapper.RegisterServices(container, loggerFactory);
            Bootstrapper.RegisterServices(container, loggerFactory);
            
            if (!includeInsulation)
                return container;

            Assembly insulationAssembly = null;
            try {
                insulationAssembly = Assembly.Load("Exceptionless.Insulation");
            } catch (Exception ex) {
                logger.Error(ex, "Unable to load the insulation assembly.");
            }

            if (insulationAssembly != null) {
                var bootstrapperType = insulationAssembly.GetType("Exceptionless.Insulation.Bootstrapper");
                if (bootstrapperType == null)
                    return container;

                bootstrapperType.GetMethod("RegisterServices", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[] { container, loggerFactory });
            }

            return container;
        }
示例#5
0
        private static void RunJobs(Container container, LoggerFactory loggerFactory, ILogger logger, CancellationToken token = default(CancellationToken)) {
            if (!Settings.Current.RunJobsInProcess) {
                logger.Info("Jobs running out of process.");
                return;
            }
            
            new JobRunner(container.GetInstance<EventPostsJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(2)).RunInBackground(token);
            new JobRunner(container.GetInstance<EventUserDescriptionsJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(3)).RunInBackground(token);
            new JobRunner(container.GetInstance<EventNotificationsJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(5)).RunInBackground(token);
            new JobRunner(container.GetInstance<MailMessageJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(5)).RunInBackground(token);
            new JobRunner(container.GetInstance<WebHooksJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(5)).RunInBackground(token);
            new JobRunner(container.GetInstance<CloseInactiveSessionsJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(30), interval: TimeSpan.FromMinutes(1)).RunInBackground(token);
            new JobRunner(container.GetInstance<DailySummaryJob>(), loggerFactory, initialDelay: TimeSpan.FromMinutes(1), interval: TimeSpan.FromHours(1)).RunInBackground(token);
            new JobRunner(container.GetInstance<DownloadGeoIPDatabaseJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(5), interval: TimeSpan.FromDays(1)).RunInBackground(token);
            new JobRunner(container.GetInstance<RetentionLimitsJob>(), loggerFactory, initialDelay: TimeSpan.FromMinutes(15), interval: TimeSpan.FromDays(1)).RunInBackground(token);
            new JobRunner(container.GetInstance<WorkItemJob>(), loggerFactory, initialDelay: TimeSpan.FromSeconds(2), instanceCount: 2).RunInBackground(token);

            logger.Warn("Jobs running in process.");
        }