@@ -549,7 +549,7 @@ class ClusterFormationTasks {
549549 static Task configureWaitTask (String name , Project project , List<NodeInfo > nodes , List<Task > startTasks ) {
550550 Task wait = project. tasks. create(name : name, dependsOn : startTasks)
551551 wait. doLast {
552- ant. waitfor(maxwait : ' 60 ' , maxwaitunit : ' second' , checkevery : ' 500' , checkeveryunit : ' millisecond' , timeoutproperty : " failed${ name} " ) {
552+ ant. waitfor(maxwait : ' 30 ' , maxwaitunit : ' second' , checkevery : ' 500' , checkeveryunit : ' millisecond' , timeoutproperty : " failed${ name} " ) {
553553 or {
554554 for (NodeInfo node : nodes) {
555555 resourceexists {
@@ -576,7 +576,7 @@ class ClusterFormationTasks {
576576 anyNodeFailed |= node. failedMarker. exists()
577577 }
578578 if (ant. properties. containsKey(" failed${ name} " . toString()) || anyNodeFailed) {
579- waitFailed(nodes, logger, ' Failed to start elasticsearch' )
579+ waitFailed(project, nodes, logger, ' Failed to start elasticsearch' )
580580 }
581581
582582 // go through each node checking the wait condition
@@ -593,14 +593,14 @@ class ClusterFormationTasks {
593593 }
594594
595595 if (success == false ) {
596- waitFailed(nodes, logger, ' Elasticsearch cluster failed to pass wait condition' )
596+ waitFailed(project, nodes, logger, ' Elasticsearch cluster failed to pass wait condition' )
597597 }
598598 }
599599 }
600600 return wait
601601 }
602602
603- static void waitFailed (List<NodeInfo > nodes , Logger logger , String msg ) {
603+ static void waitFailed (Project project , List<NodeInfo > nodes , Logger logger , String msg ) {
604604 for (NodeInfo node : nodes) {
605605 if (logger. isInfoEnabled() == false ) {
606606 // We already log the command at info level. No need to do it twice.
@@ -620,6 +620,17 @@ class ClusterFormationTasks {
620620 logger. error(" |\n | [log]" )
621621 node. startLog. eachLine { line -> logger. error(" | ${ line} " ) }
622622 }
623+ if (node. pidFile. exists() && node. failedMarker. exists() == false &&
624+ (node. httpPortsFile. exists() == false || node. transportPortsFile. exists() == false )) {
625+ logger. error(" |\n | [jstack]" )
626+ String pid = node. pidFile. getText(' UTF-8' )
627+ ByteArrayOutputStream output = new ByteArrayOutputStream ()
628+ project. exec {
629+ commandLine = [" ${ project.javaHome} /bin/jstack" , pid]
630+ standardOutput = output
631+ }
632+ output. toString(' UTF-8' ). eachLine { line -> logger. error(" | ${ line} " ) }
633+ }
623634 logger. error(" |-----------------------------------------" )
624635 }
625636 throw new GradleException (msg)
0 commit comments