Skip to content

Commit

Permalink
If there's no settings defined, it will be null and boot will fail 🤦
Browse files Browse the repository at this point in the history
  • Loading branch information
nul800sebastiaan committed Sep 18, 2023
1 parent 622d88f commit 3eb3db0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Cultiv.Hangfire/HangfireComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Extensions;

namespace Cultiv.Hangfire;
namespace Cultiv.Hangfire;

public class HangfireComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
var settings = builder.Config.GetSection("Hangfire:Server").Get<HangfireSettings>();
builder.ManifestFilters().Append<ManifestFilter>();
public void Compose(IUmbracoBuilder builder)
{
var settings = builder.Config.GetSection("Hangfire:Server").Get<HangfireSettings>();

builder.ManifestFilters().Append<ManifestFilter>();

var provider = builder.Config.GetConnectionStringProviderName(Umbraco.Cms.Core.Constants.System.UmbracoConnectionName);

if (provider.InvariantEquals("Microsoft.Data.SQLite"))
{
GlobalConfiguration.Configuration.UseSQLiteStorage();

builder.Services.AddHangfire(configuration =>
{
configuration
Expand All @@ -44,12 +44,12 @@ public void Compose(IUmbracoBuilder builder)
.UseConsole();
});

if (!settings.Disabled.GetValueOrDefault(false))
if (settings != null && !settings.Disabled.GetValueOrDefault(false))
{
// Run the required server so your queued jobs will get executed
builder.Services.AddHangfireServer();
}

AddAuthorizedUmbracoDashboard(builder);

return;
Expand Down Expand Up @@ -92,12 +92,12 @@ public void Compose(IUmbracoBuilder builder)
});
});

if (!settings.Disabled.GetValueOrDefault(false))
if (settings != null && !settings.Disabled.GetValueOrDefault(false))
{
// Run the required server so your queued jobs will get executed
builder.Services.AddHangfireServer();
// Run the required server so your queued jobs will get executed
builder.Services.AddHangfireServer();
}

AddAuthorizedUmbracoDashboard(builder);
// For some reason we need to give it the connection string again, else we get this error:
// https://discuss.hangfire.io/t/jobstorage-current-property-value-has-not-been-initialized/884
Expand Down

0 comments on commit 3eb3db0

Please sign in to comment.