我的网络作业是一项连续的工作,就像它应该循环播放一样,这样它就不会停止运行。我有一个小的错误处理程序,它将重新启 Action 业5次,直到它在代码中停用了作业本身。很好

但是,如果第一次将它重新启动,则将WEBJOBS_RESTART_TIME设置为0或类似以下示例中的内容。我不知道为什么,我知道这只是一件小事,但是下次重新启动时,一切都非常完美。

这里是0秒:

[11/30/2018 10:57:27 > 2f0a74: SYS ERR ] Job failed due to exit code -1
[11/30/2018 10:57:27 > 2f0a74: SYS INFO] Process went down, waiting for 0 seconds
[11/30/2018 10:57:27 > 2f0a74: SYS INFO] Status changed to PendingRestart
[11/30/2018 10:57:28 > 2f0a74: SYS INFO] Run script 'run.bat' with script host - 'WindowsScriptHost'
[11/30/2018 10:57:28 > 2f0a74: SYS INFO] Status changed to Running

这是重启后的运行:
[11/30/2018 10:59:07 > 2f0a74: SYS ERR ] Job failed due to exit code -1
[11/30/2018 10:59:07 > 2f0a74: SYS INFO] Process went down, waiting for 60 seconds
[11/30/2018 10:59:07 > 2f0a74: SYS INFO] Status changed to PendingRestart
[11/30/2018 11:00:09 > 2f0a74: SYS INFO] Run script 'run.bat' with script host - 'WindowsScriptHost'
[11/30/2018 11:00:09 > 2f0a74: SYS INFO] Status changed to Running

这就是它的外观。 60秒重启时间。
为什么第一次是0?

最佳答案

我研究了Github Kudu repo中的WEBJOBS_RESTART_TIME配置设置。如果搜索代码WEBJOBS_RESTART_TIME,您将找到为其定义的varibale WebJobsRestartTime 用作别名,如下所示。

public const string WebJobsRestartTime = "WEBJOBS_RESTART_TIME";

然后,继续搜索WebJobsRestartTime,这里有a code comment解释您怀疑的060的等待时间。
// The wait time between WebJob invocations is either WebJobsRestartTime (60 seconds by default) or if the WebJob
// Was running for at least 2 minutes there is no wait time.

关于c# - Azure Webjob在0秒后重新启动。为什么?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53556735/

10-08 23:04