提交 2f3b95ad 编写于 作者: K kohsuke

If a build appears to be hanging for too long, Hudson turns the progress bar to red.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13041 71c3de6d-444a-0410-be80-ed276b4c234a
上级 ff5958ab
......@@ -12,6 +12,7 @@ import javax.servlet.ServletException;
import java.io.IOException;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.concurrent.TimeUnit;
/**
......@@ -184,6 +185,29 @@ public class Executor extends Thread implements ModelObject {
return num;
}
/**
* Returns true if the current build is likely stuck.
*
* <p>
* This is a heuristics based approach, but if the build is suspiciously taking for a long time,
* this method returns true.
*/
@Exported
public boolean isLikelyStuck() {
Queue.Executable e = executable;
if(e==null) return false;
long elapsed = System.currentTimeMillis() - startTime;
long d = e.getParent().getEstimatedDuration();
if(d>=0) {
// if it's taking 10 times longer than ETA, consider it stuck
return d*10 < elapsed;
} else {
// if no ETA is available, a build taking longer than a day is considered stuck
return TimeUnit.MILLISECONDS.toHours(elapsed)>24;
}
}
/**
* Computes a human-readable text that shows the expected remaining time
* until the build completes.
......
......@@ -6,5 +6,6 @@
-->
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<t:progressBar tooltip="${%text(build.timestampString,build.executor.estimatedRemainingTime)}"
red="${build.executor.isLikelyStuck()}"
pos="${build.executor.progress}" href="${rootURL}/${build.url}console"/>
</j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册