Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • lucuma 261 posts 563 karma points
    Jan 08, 2016 @ 15:06
    lucuma
    0

    Hangfire Always On IIS 7.5/8.0 and Preloading

    I'm using Hangfire and Umbraco and am using some of the umbraco services in the business layer that runs in Hangfire. These are being registered in an IOC container like this:

    container.Register<IMemberService>((f)=>ContextHelpers.EnsureUmbracoContext().Application.Services.MemberService, new PerScopeLifetime());
                container.Register<IMemberGroupService>((f) => ContextHelpers.EnsureUmbracoContext().Application.Services.MemberGroupService, new PerScopeLifetime());
    

    All this works great until I enable the always on preloader to ensure that Hangfire is always running. The ApplicationContext.Current is null. Is there a better way or alternate way to do the EnsureUmbracoContext so that it is initialized in the preloader?

    Error:

    Message: Current has not been initialized on Umbraco.Web.Routing.UrlProviderResolver. You must initialize Current before trying to read it.
    

    Preloader:

     public class AlwaysOn : System.Web.Hosting.IProcessHostPreloadClient
        {
            public void Preload(string[] parameters)
            {
                 // var u = new UmbracoHangFireBase();
                 // u.Start(u, new EventArgs()); 
                 // didn't work
    
                HangfireBootstrapper.Instance.Start();  // http://hangfirechinese.readthedocs.org/en/latest/deployment-to-production/making-aspnet-app-always-running.html
            }
        }
    
  • lucuma 261 posts 563 karma points
    Jan 12, 2016 @ 15:02
    lucuma
    0

    I went a different route using the iis extension to autoload the site. Seems to be working fine.

  • Michael 2 posts 71 karma points
    Feb 25, 2016 @ 04:32
    Michael
    0

    I'm having the same issue.

    I'm thinking it's because Hangfire BackgroundJobServer is not being instantiated in the OWIN start up, but in IProcessHostPreloadClient.Preload.

    Would love a fix or some tips...

Please Sign in or register to post replies

Write your reply to:

Draft