Azure Webjob 在 0 秒后重新启动。为什么?
Azure Webjob restarts in 0 seconds. Why?
我的 webjob 是一个连续的工作,就像它应该在一个循环中一样,所以它不会停止 运行ning。我有一个小错误处理,它会重新启动作业 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. If searched for code WEBJOBS_RESTART_TIME
, you will find the varibale WebJobsRestartTime
中的 WEBJOBS_RESTART_TIME
配置设置,定义为它用作别名,如下所示。
public const string WebJobsRestartTime = "WEBJOBS_RESTART_TIME";
然后,继续搜索WebJobsRestartTime
,有a code comment说明等待时间0
和60
你疑惑
// 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.
我的 webjob 是一个连续的工作,就像它应该在一个循环中一样,所以它不会停止 运行ning。我有一个小错误处理,它会重新启动作业 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. If searched for code WEBJOBS_RESTART_TIME
, you will find the varibale WebJobsRestartTime
中的 WEBJOBS_RESTART_TIME
配置设置,定义为它用作别名,如下所示。
public const string WebJobsRestartTime = "WEBJOBS_RESTART_TIME";
然后,继续搜索WebJobsRestartTime
,有a code comment说明等待时间0
和60
你疑惑
// 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.