计划的 WebJob 长时间运行时会发生什么 [英] What happens when a scheduled WebJob runs for a long time

查看:19
本文介绍了计划的 WebJob 长时间运行时会发生什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果 Azure WebJob 计划运行但之前运行的实例尚未完成,会发生什么情况?它会再次运行 WebJob 以便同时运行两个吗?它不会运行 WebJob 并重新开始计时吗?我无法在任何地方找到这种行为记录.我有一份工作,我想每小时运行一次,但有时可能需要超过一个小时才能完成,但我不希望其中两个同时运行.

What happens if an Azure WebJob is scheduled to run but the previous running instance hasn't finished yet? Will it run the WebJob again so that two are running at once? Will it not run the WebJob and start the clock over? I haven't been able to find this behavior documented anywhere. I have a job I want to run hourly but it's possible that sometimes it might take longer than an hour to complete, but I never want two of them running at once.

推荐答案

据我了解,调度的 webjobs 只是使用 Azure Scheduler 运行的触发 webjobs,如果您在管理门户中打开 Azure Scheduler,您可以看到 webjobs 甚至配置他们更详细.(您也可以查看日志,这将为您的问题提供简单的答案).

As i understand it scheduled webjobs is just triggered webjobs that is run using Azure Scheduler, if you open Azure Scheduler in management portal you can see the webjobs and even configure them in more detail. (You can see the log too which would give you the simple answer to your question).

如果你想看看你计划的 webjob 是由 Kudu 作为触发 webjob 运行的,如果你查看 Kudu 源代码,你会看到在启动作业时会创建一个锁定文件,如果你尝试开始另一个作业如果已经有一个锁文件会抛出一个ConflictException

If you like to look at whats going on your scheduled webjob is run as a Triggered webjob by Kudu, if you look in the Kudu source you will see that a lockfile is created when a job is started, and if you try to start another job a ConflictException is thrown if there is already a lock file

Azure 调度程序使用 捕获 ConflictException 的 webhook 调用您的作业并为您提供Error_WebJobAlreadyRunning"警告,它会告诉您:由于作业已经在运行,因此无法开始新的运行."

The Azure scheduler calls your job using a webhook that catches the ConflictException and gives you the "Error_WebJobAlreadyRunning" warning which will tell you: "Cannot start a new run since job is already running."

这篇关于计划的 WebJob 长时间运行时会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆