除非打开仪表板,否则Hang​​fire不会处理周期性作业 [英] Hangfire does not process recurring jobs unless dashboard is open

查看:91
本文介绍了除非打开仪表板,否则Hang​​fire不会处理周期性作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我登录服务器并打开仪表板时,它显示了过去执行下一次执行的重复作业.在几秒钟内,它会自动触发对它们的处理,但是,如果我不登录并打开仪表板,则不会触发重复作业.

When I log into the server and open dashboard, it shows recurring jobs with the next execution in the past. Within seconds it triggers processes them automatically, but if I don't log in and open the dashboard, the recurring jobs are not triggered.

Hangfire似乎正在按预期方式运行并正在处理作业.
如果没有我看,为什么它不会触发?

It appears that Hangfire is running as expected and processing jobs.
Why will it not trigger without me looking at it?

推荐答案

如果Hangfire服务器在 Web应用程序中运行,这是一个常见问题.未触发作业,因为Web服务器由于用户不活动而停止了该应用程序.

It's a usual problem if a Hangfire server runs in a web application. The jobs are not triggered because the web server has stopped the app due to user inactivity.

默认情况下,Web应用程序中的Hangfire Server实例不会 开始,直到第一个用户访问您的网站.甚至还有一些 一段时间后会导致您的网络应用程序崩溃的事件(我是 谈论空闲超时和不同的应用程序池回收事件). 在这些情况下,您的重复任务和延迟的工作将不会 排队,排队的作业将不被处理.

By default, Hangfire Server instance in a web application will not be started until the first user hits your site. Even more, there are some events that will bring your web application down after some time (I’m talking about Idle Timeout and different app pool recycling events). In these cases your recurring tasks and delayed jobs will not be enqueued, and enqueued jobs will not be processed.

阅读文档以防止出现这种情况:

Read the docs to prevent it: Making ASP.NET application always running.

另一种解决方案是将Hangfire服务器从Web应用程序迁移到控制台应用程序或Windows服务.

Another solution is to migrate your Hangfire server from a web application to a console app or a windows service.

这篇关于除非打开仪表板,否则Hang​​fire不会处理周期性作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆