Hi, Ive got hang fire core installed and loading the dashboard on a MVC ASP.NET CORE Appication.
I do however get multiple servers in the dashboard, more get added each time I start the debugger.
Some times I also get it hanging on boot up.
Any suggestions?
below is my startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Core.Data;
using Core.Models;
using Core.Services;
using Microsoft.AspNetCore.Cors;
using Microsoft.Extensions.FileProviders;
using System.IO;
using Microsoft.AspNetCore.Http;
using System.Globalization;
using Hangfire;
using Hangfire.PostgreSql;
using Npgsql;
public void ConfigureServices(IServiceCollection services)
{
var connectionString = Configuration["DbContextSettings:ConnectionString"];
services.AddDbContext<ApplicationDbContext>(
opts => opts.UseNpgsql(connectionString)
);
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
//postgress support
services.AddEntityFrameworkNpgsql()
.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(Configuration["DbContextSettings:ConnectionString"]))
.AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql(Configuration["DbContextSettings:ConnectionString"]));
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services.AddSingleton<IConfiguration>(Configuration);
services.Configure<KaceSettings>(Configuration.GetSection("KaceSettings"));
//hangfire
services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin()));
string sConnectionString = connectionString;
var sb = new NpgsqlConnectionStringBuilder(sConnectionString)
{
Pooling = false
};
var storage = new PostgreSqlStorage(sb.ConnectionString);
services.AddMvc();
Hangfire.GlobalConfiguration.Configuration.UseStorage(storage);
services.AddHangfire(c => c.UseStorage(storage));
this.Seed();
//new ApplicationDbContext().Database.Migrate();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseFileServer(new FileServerOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), @"custom_modules")),
RequestPath = new PathString("/custom_modules"),
EnableDirectoryBrowsing = true
});
app.UseStaticFiles();
app.UseIdentity();
//hangfire
app.UseHangfireServer(new BackgroundJobServerOptions(),null, new PostgreSqlStorage(Configuration["DbContextSettings:ConnectionString"]));
app.UseHangfireDashboard();