webjob因为长时间闲置而异常中止

时间:2017-12-12 08:56:10

标签: azure azure-webjobs

我在azure webjob上提取.zip存档。

一段时间以来一直运作良好。

现在,webjob突然失败了:

[12/11/2017 16:59:57 > bf607f: ERR ] Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""run.cmd""
[12/11/2017 16:59:57 > bf607f: ERR ] replace D:\home\site\store\extracted/documents/6465465465466015.pdf? [y]es, [n]o, [A]ll, [N]one, [r]ename: 
[12/11/2017 16:59:57 > bf607f: SYS INFO] Status changed to Failed
[12/11/2017 16:59:57 > bf607f: SYS ERR ] System.AggregateException: One or more errors occurred. ---> Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""run.cmd""
   at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process)
   at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Kudu.Core.Infrastructure.Executable.ExecuteInternal(ITracer tracer, Func`2 onWriteOutput, Func`2 onWriteError, Encoding encoding, String arguments, Object[] args)
   at Kudu.Core.Infrastructure.Executable.ExecuteReturnExitCode(ITracer tracer, Action`1 onWriteOutput, Action`1 onWriteError, String arguments, Object[] args)
   at Kudu.Core.Jobs.BaseJobRunner.RunJobInstance(JobBase job, IJobLogger logger, String runId, String trigger, ITracer tracer, Int32 port)
---> (Inner Exception #0) ExitCode: -1, Output: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Error: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed., Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""run.cmd""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""run.cmd""
   at Kudu.Core.Infrastructure.IdleManager.WaitForExit(IProcess process)
   at Kudu.Core.Infrastructure.ProcessExtensions.<Start>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Kudu.Core.Infrastructure.Executable.<ExecuteAsync>d__31.MoveNext()<---

我的意思是,当异常发生时,webjob非常繁忙,为什么我会得到那个空闲超时异常?

2 个答案:

答案 0 :(得分:2)

我建议您使用您选择的值在Web App“应用程序设置”配置中添加SCM_COMMAND_IDLE_TIMEOUT和WEBJOBS_IDLE_TIMEOUT设置。

例如:

SCM_COMMAND_IDLE_TIMEOUT = 3600

WEBJOBS_IDLE_TIMEOUT = 3600

如果未启用,您可以打开“始终开启”功能,看看是否有帮助。

默认情况下,如果Web应用程序闲置一段时间,则会将其卸载。这使系统可以节省资源。在“基本”或“标准”模式下,您可以启用“始终开启”以始终加载应用程序。如果您的应用运行连续的WebJobs,则应启用“始终开启”,否则WebJobs可能无法可靠运行。要启用,转到网络应用程序 - &gt;设置 - &gt;应用程序设置 - &gt;启用“始终开启”。

另外,请参阅diagnostic log stream以获取有关此问题的更多详细信息。

答案 1 :(得分:1)

  

我的意思是,当异常发生时,webjob非常繁忙,为什么我会得到那个空闲超时异常?

根本原因:

控制台中没有输出很长时间。

<强>解决方案:

我们也可以这样做,因为Ashok提到增加 WEBJOBS_IDLE_TIMEOUT 值。这应该在Web应用程序的配置设置中设置,而不是在App.config中设置。 WebJob。价值是秒。

您还可以每分钟向控制台添加输出。更多细节可以参考此blog

  

另一个解决方案是将输出添加到控制台,这对于执行长时间运行异步任务或轮询外部服务的作业特别有用。对于这些情况,添加心跳样式控制台每分钟写入是比将空闲超时增加到更大数量更好