From 123af4f44dab6a0495f103569055a319017f045c Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Wed, 13 Apr 2016 10:48:06 -0400 Subject: [PATCH] Add configuration for queue processing interval --- Web/HangfireStartup.cs | 9 +++++---- Web/Web.config | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Web/HangfireStartup.cs b/Web/HangfireStartup.cs index 32a37be..e5a412c 100644 --- a/Web/HangfireStartup.cs +++ b/Web/HangfireStartup.cs @@ -3,7 +3,9 @@ using Hangfire; using Microsoft.Owin; using LeafWeb.Web; using LeafWeb.Web.Services; +using NLog.Internal; using Owin; +using ConfigurationManager = System.Configuration.ConfigurationManager; [assembly: OwinStartup(typeof(HangfireStartup))] @@ -15,9 +17,6 @@ namespace LeafWeb.Web public void Configuration(IAppBuilder app) { - //GlobalConfiguration.Configuration - // .UseSqlServerStorage("LeafWebContext"); - app.UseHangfireDashboard(); app.UseHangfireServer(); @@ -27,8 +26,9 @@ namespace LeafWeb.Web private void SetupRecurringJobs() { // TODO: new SqlServerDistributedLock + var queueInterval = ConfigurationManager.AppSettings["ProcessQueueInterval"]; // https://discuss.hangfire.io/t/how-to-create-cron-job-that-is-executing-every-15-minutes/533 - RecurringJob.AddOrUpdate(PiscalProcessQueue, p => p.ProcessQueue(), "*/15 * * * *"); + RecurringJob.AddOrUpdate(PiscalProcessQueue, p => p.ProcessQueue(), queueInterval); } public static void TriggerPiscalProcessQueue() @@ -81,6 +81,7 @@ namespace LeafWeb.Web { lock (_lockObject) { + _backgroundJobServer?.Dispose(); HostingEnvironment.UnregisterObject(this); diff --git a/Web/Web.config b/Web/Web.config index 24bc764..6205ff4 100644 --- a/Web/Web.config +++ b/Web/Web.config @@ -24,6 +24,7 @@ +