c# - Hangfire 后台作业神秘地停止运行

标签 c# asp.net-web-api background-process jobs hangfire

我有一个关于 Hangfire 1.4.3.0(WebAPI,SQL 服务器存储)的奇怪问题 - 在作业开始整整 30 分钟后,hangfire 重新启动它并分配一个新的工作人员。跟踪级别的默认 hangfire 日志记录没有显示任何有用的信息。在我的网络应用程序日志中,我只能看到该作业已启动,hangfire 数据库中的状态表显示已分配新工作人员:

Id  JobId   Name    Reason  CreatedAt   Data
27  8   Processing  NULL    2017-05-17 10:34:51.640 {"StartedAt":"2017-05-17T10:34:51.6389278Z","ServerId":"mypc:3332","WorkerNumber":"22"}
28  8   Processing  NULL    2017-05-17 11:04:51.683 {"StartedAt":"2017-05-17T11:04:51.6819303Z","ServerId":"mypc:3332","WorkerNumber":"14"}

但是以前的 worker 怎么了?我如何找出停止的原因?

最佳答案

在谷歌搜索相同问题后,我从下面的链接找到了解决方案,其中提到了一些配置部分,这对于连续运行您的工作非常重要。

http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html

-----以下是您必须在全局 applicationHost.config 文件 (%WINDIR%\System32\inetsrv\config\applicationHost.config) 中进行的配置。

<applicationPools>
    <add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>

<!-- ... -->

<sites>
    <site name="MySite" id="1">
        <application path="/" serviceAutoStartEnabled="true"
                              serviceAutoStartProvider="ApplicationPreload" />
    </site>
</sites>

<!-- Just AFTER closing the `sites` element AND AFTER `webLimits` tag -->
<serviceAutoStartProviders>
    <add name="ApplicationPreload" type="WebApplication1.ApplicationPreload, WebApplication1" />
</serviceAutoStartProviders>

关于c# - Hangfire 后台作业神秘地停止运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44027059/

相关文章:

c# - 自动生成的 XAML.g.cs 文件在 Xamarin Forms PCL 项目中不可编译

web-services - 服务层和 Web API 服务层?

asp.net-mvc - 无法使用 Windsor 容器将依赖项注入(inject) Asp.net MVC 4 Web API Controller

ios - 我可以使用 Apple 推送通知服务让我的应用程序在不通知 iOS 7 中的用户的情况下执行某些操作吗

c# - 在 WebApi 中使用 OAuth Bearer Tokens Generation 和 Owin 将更多信息返回给客户端

c# - 构造类的属性只能在构造函数中设置,但在哪里?

c# - 如何在 C# 中将 Linq count 与 group by 一起使用

asp.net - 如何在 web api 2 中获取和设置 cookie

java - 定期扫描用户位置并更新本地数据库的后台进程,即使在应用程序未打开时也是如此

reactjs - react-native-background-timer, null 不是一个对象