asp.net-core - 如何在控制台应用程序中配置 hangfire 仪表板?
问题描述
我正在使用 hangfire nuget 包来安排 asp.net 核心控制台应用程序中的作业
我尝试了所有将仪表板配置到控制台应用程序的方法
我如何从控制台应用程序托管网页???
我为仪表板配置创建了 startup.cs 类
using Hangfire;
using Microsoft.AspNetCore.Builder;
namespace PulsarHangFire
{
public class Startup
{
public void Configuration(IApplicationBuilder app)
{
app.UseHangfireDashboard("/hangfire");
app.UseHangfireServer();
}
}
}
谁能告诉我我该如何前进
解决方案
创建一个 Startup.cs 文件(或从 .NET Core Web App 模板中获取一个)并配置以下内容:
public void ConfigureServices(IServiceCollection services)
{
// ... other required services ...
services.AddHangfire(configuration =>
{
// Do pretty much the same as you'd do with
// GlobalConfiguration.Configuration in classic .NET
// NOTE: logger and activator would be configured automatically,
// and in most cases you don't need to configure those.
configuration.UseSqlServerStorage(...);
// ... maybe something else, e.g. configuration.UseConsole()
});
}
最后添加 Hangfire 仪表板:
public void Configure(IApplicationBuilder app, IRecurringJobManager recurringJobManager)
{
// ... previous pipeline stages, e.g. app.UseAuthentication()
app.UseHangfireDashboard(...);
// ... next pipeline stages, e.g. app.UseMvc()
// then you may configure your recurring jobs here:
recurringJobManager.AddOrUpdate(...);
}
推荐阅读
- go - 使用 JWT 的 GraphQL Golang 身份验证
- javascript - Next.js:react-color - 警告:道具`style`不匹配
- angular - 如何确保用户输入图像(FORM ANGULAR)
- c - 如何在退出 C 中的 Do While 循环后使用在 Do While 循环中输入的值
- python - DynamicMap 不会随着 Holoviews 中变量的变化而更新
- android-studio - Android Studio Virtual Device 错误启动设备
- powershell - Powershell - 为什么从库中下载此模块在服务器上失败?
- assembly - 为什么堆栈上的地址要远 8 个字节?
- r - 如何通过 R 中的日期列表应用 API 查询?
- r - Table() 函数的问题