【发布时间】:2017-04-24 08:47:26
【问题描述】:
我有一个像下面这样的 ANT 目标:
<target name="validate_master_resources" description="Ensure the target is valid for local test run">
<exec executable="bash" outputproperty="swap">
<arg value="-c"/>
<arg value="free -m | grep '^Swap:' | awk '{print $4}'"/>
</exec>
<if>
<islessthan arg1="${swap}" arg2="5000"/>
<then>
<echo>the value of the swap memory is: ${swap}</echo>
<sleep minutes="10"/>
<runtarget target="validate_master_resources"/>
</then>
</if>
</target>
正如您所见,它是一种递归目标,如果遇到某些条件,validate_master_resources 会调用自己。
我决定使用 runtarget(而不是 ant 调用),以避免创建新的 ANT 进程。
该作业在临时测试了几分钟后,按预期工作,但在前 2 次“真实世界”运行中,它在 20 分钟后卡住了...
我在 Jenkins 中运行这项工作,正如所说的那样,这项工作在 20 分钟后卡住了
正如你在下面看到的,它被调用了很多次然后卡住了几个小时,我需要杀死它......
validate_master_resources:
[echo] The number of current Java processes is: 33 summed to the 45 is 78
validate_master_resources:
[echo] The number of current Java processes is: 33 summed to the 45 is 78
validate_master_resources:
[echo] The number of current Java processes is: 33 summed to the 45 is 78
validate_master_resources:
[echo] The number of current Java processes is: 33 summed to the 45 is 78
validate_master_resources:
[echo] The number of current Java processes is: 33 summed to the 45 is 78
validate_master_resources:
[echo] The number of current Java processes is: 33 summed to the 45 is 78
现在,我的问题是,这个问题(构建卡住)是否与这个 ant 任务是递归的有关?
是否有任何任务流程/标签可以帮助我管理这样的递归?
我是否在非法模式下使用任务,错误行为取决于我创建的这个特定循环?
谢谢
【问题讨论】:
-
“if”和“runtarget”任务都是 ANT 扩展的一部分,称为 ant-contrib。两者都不是标准 ANT 的一部分
-
是的,那我知道了?
标签: recursion ant ant-contrib