hangfire

How to get IIS site to start up automatically after deployment?

一个人想着一个人 提交于 2019-11-28 03:28:09
问题 I have a Web API service that I'm deploying to my various environments (using Octopus Deploy). It is supposed to do various tasks on startup, e.g. run any migration scripts required by Entity Framework Code First, and some background tasks managed by Hangfire. Trouble is, the web site only wakes up the first time someone makes a call to it. I want it to run as soon as I've deployed it. I could do it manually just by pointing a web browser at the API's home page, but that requires me to

Hangfire dependency injection with .net core

北城余情 提交于 2019-11-27 20:21:59
问题 How can I use .net core's default dependency injection in Hangfire ? I am new to Hangfire and searching for an example which works with asp.net core. 回答1: See full example on GitHub https://github.com/gonzigonz/HangfireCore-Example. Live site at http://hangfirecore.azurewebsites.net/ Make sure you have the Core version of Hangfire: dotnet add package Hangfire.AspNetCore Configure your IoC by defining a JobActivator . Below is the config for use with the default asp.net core container service:

Hangfire 服务器唤醒后,阻止执行错过的作业

久未见 提交于 2019-11-27 16:03:34
原文: https://github.com/HangfireIO/Hangfire/issues/620 /// <summary> /// 错过不执行 /// </summary> public class NoMissedRunsAttribute : JobFilterAttribute, IClientFilter { /// <summary> /// 设置逾期时间 /// </summary> public TimeSpan MaxDelay { get; set; } = TimeSpan.FromMinutes(15); public void OnCreating(CreatingContext context) { if (context.Parameters.TryGetValue("RecurringJobId", out var recurringJobId) && context.InitialState?.Reason == "Triggered by recurring job scheduler") { // the job being created looks like a recurring job instance, // and triggered by a scheduler (i.e. not manually) at that.

Configure cron job that is executing every 15 minutes on Hangfire

蓝咒 提交于 2019-11-27 15:35:15
问题 I am using Hangfire and like the software very much! But one thing I am missing is how to add a recurring job that executes every few minutes (e.g. every 15 minutes). Is there a way to achieve this? 回答1: Currently I am using this approach: RecurringJob.AddOrUpdate(() => Console.Write("Recurring"), "*/15 * * * *"); And is working like a charm. Reference to my question in Hangfire forums: http://discuss.hangfire.io/t/how-to-create-cron-job-that-is-executing-every-15-minutes/533 回答2: Looking at

Resolving type with PerRequestLifetimeManager without HTTP request

好久不见. 提交于 2019-11-27 14:51:54
I have a MVC application that uses IoC with Unity and I have a DbContext implementation defined using the PerRequestLifetimeManager . This object is injected to controllers through Unit of Work implementation. container.RegisterType<DBContext, MyContext>(new PerRequestLifetimeManager()); Everything is working fine so far and the app has a decent number of models and controllers. Now what I was trying to do recently is add some automated tasks for this application and for this purpose I wanted to use HangFire . I've set up this library in my project and created a simple task in which I want to

Where am I supposed to start persistent background tasks in ASP.NET Core?

巧了我就是萌 提交于 2019-11-27 06:24:20
问题 In my web application (ASP.NET Core), I want to run a job in the background that is listening to a remote server, calculating some results and pushing it to the client on Pusher (a websocket). I'm not sure where I'm supposed to start this task. Currently I start it at the end of public void Configure(IApplicationBuilder app, IHostingEnvironment env) in Startup.cs but I think there is something wrong about that, it doesn't make sense to start background jobs in a method called "Configure". I

Why is Hangfire requiring authentication to view dashboard

社会主义新天地 提交于 2019-11-27 02:20:26
问题 I am running HangFire within my MVC web app but whenever I try to navigate to http://MyApp/hangfire, it redirects me to my app's login page as though I am not logged in. I have not explicitly configured any requirements for authorization...e.g. I had the below in the web.config, but then took it out in attempts to get this to work. <location path="hangfire"> <system.web> <authorization> <allow roles="Administrator" /> <deny users="*" /> </authorization> </system.web> In theory, this is what I

Resolving type with PerRequestLifetimeManager without HTTP request

我只是一个虾纸丫 提交于 2019-11-26 16:56:30
问题 I have a MVC application that uses IoC with Unity and I have a DbContext implementation defined using the PerRequestLifetimeManager . This object is injected to controllers through Unit of Work implementation. container.RegisterType<DBContext, MyContext>(new PerRequestLifetimeManager()); Everything is working fine so far and the app has a decent number of models and controllers. Now what I was trying to do recently is add some automated tasks for this application and for this purpose I wanted

asp.net core 中hangfire面板的配置及使用

◇◆丶佛笑我妖孽 提交于 2019-11-26 12:40:35
1、定义校验授权类DyDashboardAuthorizationFilter /// <summary> /// Hangfire仪表盘配置授权 /// </summary> public class MyDashboardAuthorizationFilter : IDashboardAuthorizationFilter { public bool Authorize([NotNull] DashboardContext context) { var httpContext = context.GetHttpContext(); var header = httpContext.Request.Headers["Authorization"]; if (string.IsNullOrWhiteSpace(header)) { SetChallengeResponse(httpContext); return false; } var authValues = System.Net.Http.Headers.AuthenticationHeaderValue.Parse(header); if (!"Basic".Equals(authValues.Scheme, StringComparison.InvariantCultureIgnoreCase)) {