Hangfire作业未在我的Asp .Net Core网站上运行 [英] Hangfire jobs not running on my Asp .Net Core-site

查看:96
本文介绍了Hangfire作业未在我的Asp .Net Core网站上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要总结以下文本:如果我的网页上没有用户,我该怎么做才能执行Hangfire作业?

我正在运行asp net core,并已开始使用Hangfire来执行Web应用程序上的重复任务.我在周末让它在我的工作上运行,但是当我回来时,没有任何工作在运行.经过一番搜寻之后,我发现这似乎是

Im running asp net core and have started using Hangfire for recurring tasks on my web application. I left it running on my job for the weekend but when I get back no jobs has been run. After googling a bit I've got that it seems to be a "fix"/method for this on hangfires docs, but it seems to be made for non-core. Do I need a special handling for this in .Net Core (with app.UseHangFireServer() and so on?

推荐答案

问题在于,只有在通过按浏览器中的F5刷新网站后,hangfire才会唤醒.

The problem is that hangfire will only wake up after a refresh of your website by pressing F5 in the browser.

我在解决.NET核心Web服务时遇到了相同的问题,如下所述.

I was having the same issue for our .NET core webservice that I fixed as follows.

  • 我们的IIS版本: 7.5
  • 我们的服务器: Windows Server 2008 R2
  • Our IIS version : 7.5
  • Our Server : Windows Server 2008 R2

1)您将需要可以在此处下载的所谓的应用程序初始化程序: https ://www.iis.net/downloads/microsoft/application-initialization 下载并运行MSI.安装后,您可能必须重新引导服务器.

1) You will need the so called Application Initializer which you can download here: https://www.iis.net/downloads/microsoft/application-initialization Download and run the MSI. Once installed, you will probably have to reboot the server.

2)在记事本中打开位于%WINDIR%\ system32 \ inetsrv \ config 的applicationHost.config,确保使用以管理员身份运行"选项运行它. 请勿使用Notepad ++ ,请参见: https://serverfault.com/a/599865 .

2) Open applicationHost.config which is at %WINDIR%\system32\inetsrv\config in Notepad, being sure to run it with the "Run as Administrator" option. Do not use Notepad++ see: https://serverfault.com/a/599865.

3)找到配置部分,然后寻找运行图库的应用程序池.如果您不知道池名称,请在IIS管理器中通过右键单击左窗格中的应用程序节点并选择管理应用程序">高级设置"来查找它.添加 startMode =" AlwaysRunning" ,使其看起来像这样:

3) Find the configuration section, and then look for the application pool running your gallery. If you don’t know the pool name, look it up in IIS Manager by right-clicking the application node in the left pane and choosing Manage Application > Advanced Settings. Add startMode="AlwaysRunning" so that it looks like this:

<add name="OGF.Home.Webapi" autoStart="true" managedRuntimeVersion=""  startMode="AlwaysRunning" >

4)在applicationHost.config中向下滚动到配置元素.找到图库应用程序的条目,然后添加 preloadEnabled ="true"

4) Scroll down a little more in applicationHost.config to the configuration element. Find the entry for the gallery application and add preloadEnabled="true" , like this:

   <site name="OGF.Home.Webapi" id="10" serverAutoStart="true">
   <application path="/" applicationPool="OGF.Home.Webapi" preloadEnabled="true">
   ...

5)通过在以管理员身份运行的命令提示符下执行iisreset,重新启动IIS.

5) Restart IIS by executing iisreset in a command prompt running as an administrator.

对于Windows Server 2012及更高版本,您可以在安装Application Initializer之后打开应用程序池和网站的高级设置"菜单,直接在IIS中配置这些设置.

For Windows Server 2012 and higher you can configure these settings directly in IIS by opening the "Advanced Settings" menu for the application pool and the website after installing the Application Initializer.

这篇关于Hangfire作业未在我的Asp .Net Core网站上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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