我的 Azure WebJob 在运行仅 20 分钟后就失败,并显示以下日志输出:
[02/27/2015 00:30:11 > 3e9b72: SYS INFO] Status changed to Initializing
[02/27/2015 00:30:21 > 3e9b72: SYS INFO] Run script 'Namespace.Class.DataProcessor.exe' with script host - 'WindowsScriptHost'
[02/27/2015 00:30:21 > 3e9b72: SYS INFO] Status changed to Running
[02/27/2015 00:30:23 > 3e9b72: INFO] Found the following functions:
[02/27/2015 00:30:23 > 3e9b72: INFO] Namespace.Class.DataProcessor.Functions.ManualTrigger
[02/27/2015 00:30:23 > 3e9b72: INFO] Executing: 'Functions.ManualTrigger' because This was function was programmatically called via the host APIs.
[02/27/2015 00:51:35 > 3e9b72: ERR ] Thread was being aborted.
[02/27/2015 00:51:35 > 3e9b72: SYS INFO] WebJob process was aborted
[02/27/2015 00:51:35 > 3e9b72: SYS INFO] Status changed to Stopped
[02/27/2015 00:51:35 > 3e9b72: SYS INFO] Status changed to Failed
[02/27/2015 00:51:35 > 3e9b72: SYS ERR ] WebJob run failed due to: System.Threading.ThreadAbortException: Thread was being aborted.
at Kudu.Core.Jobs.BaseJobRunner.RunJobInstance(JobBase job, IJobLogger logger, String runId)
at Kudu.Core.Jobs.TriggeredJobRunner.<>c__DisplayClass2.<StartJobRun>b__0(Object _)
它按计划每天在系统安静时启动一次,20 分钟后它会因该错误而失败。 仅当调度程序自动触发作业时才会发生此错误。如果从站点下的 Azure WebJob 面板手动触发,即使运行多个小时也不会出现错误。
职位申请输出一个“.”每隔几步,就可以防止 Azure 认为它处于闲置状态。我还在运行作业的网站上配置了以下设置,以防止在需要一段时间才能响应或向日志输出内容时超时:
WEBJOBS_IDLE_TIMEOUT = 14400
SCM_COMMAND_IDLE_TIMEOUT = 14400
作业操作是触发作业的 POST 请求,我怀疑这与手动启 Action 业的机制相同(并且不会超时)。
如何防止 20 分钟后失败?我需要更改/添加什么设置才能允许作业运行超过 20 分钟?
最佳答案
确保您将网站配置为在启用“始终在线”设置的情况下运行。这需要一个标准级别的网站(免费网站不提供)。来自 documentation :
Always On. By default, web apps are unloaded if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable Always On to keep the app loaded all the time. If your app runs continuous web jobs, you should enable Always On, or the web jobs may not run reliably.
关于azure - 由于 : System. Threading.ThreadAbortException:WebJob 运行失败:线程被中止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28767115/