首页 > 解决方案 > Continuous WebJob 随机重启

问题描述

我在我的 WebApp 中运行一个连续的 WebJob。我发现它可以随机重启。我检查了我的网络应用程序设置,并且“始终开启”已打开。我没有可以导致重新启动的触发器。这是一个空的网络应用程序,从头开始创建。我所做的只是发布了我的连续 WebJob。如何防止这种随机重启?

正如我从 App Insight 中看到的,它在第一次运行 10 分钟后重新启动

2/9/2021, 12:46:45 PM - TRACE
Checking for active containers
Severity level: Information

2/9/2021, 12:46:45 PM - TRACE
Job host started
Severity level: Information

2/9/2021, 12:46:45 PM - TRACE
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Severity level: Warning

2/9/2021, 12:46:45 PM - TRACE
Starting JobHost
Severity level: Information


2/9/2021, 12:36:44 PM - TRACE
2: Change Feed Processor: Processor_Container2 with Instance name: 4b94336ff47c4678b9cf4083a60f0b3bf1cd9f77ce7d501100a9d4e60bd87e8e has been started
Severity level: Information

2/9/2021, 12:36:37 PM - TRACE
1: Change Feed Processor: Processor_Container1 with Instance name: 4b94336ff47c4678b9cf4083a60f0b3bf1cd9f77ce7d501100a9d4e60bd87e8e has been started
Severity level: Information

2/9/2021, 12:36:32 PM - TRACE
Checking for active containers
Severity level: Information

2/9/2021, 12:36:32 PM - TRACE
Job host started
Severity level: Information

标签: azureazure-web-app-serviceazure-webjobs

解决方案


请查看作业和日志以进一步隔离问题:

对于连续的 WebJobs - Console.OutConsole.Error被路由到“应用程序日志”,它们将显示为文件或 blob,具体取决于您的应用程序日志配置(类似于您的 WebApp)。

请查看此文档以获取更多详细信息 - https://github.com/projectkudu/kudu/wiki/WebJobs#logging

我见过这样的案例,在门户网站的 WebJobs 配置刀片上有不必要的应用程序设置会导致重新启动。请根据需要识别并删除不必要的应用程序设置(作为测试)。

另外,请查看此设置是否存在 '<code>**WEBJOBS_RESTART_TIM**E '-连续作业的进程停止(出于任何原因)和我们重新启动它的时间之间的超时秒数(仅适用于连续工作)。

在应用服务上,在左侧导航中,单击诊断和解决问题- 签出“<code>**Diagnostic Tools**”>“Availability and Performance”和“Best Practices”的磁贴。/查看 WebJob 详细信息(下面的屏幕截图)。

只是为了隔离,请看看设置单例是否有帮助。如果将连续作业设置为单例,它将仅在单个实例上运行,而不是在所有实例上运行。默认情况下,它在所有实例上运行。

 {


  "is_singleton": true
  }

请参阅此文档- https://github.com/projectkudu/kudu/wiki/WebJobs-API#set-a-continuous-job-as-singleton

在此处输入图像描述

PS为了使社区受益/从我们在问答线程的讨论中复制答案。


推荐阅读