Merge pull request #14839 from nik9000/startup_log

Output more information when gradle can't start elasticsearch
This commit is contained in:
Nik Everett 2015-11-18 13:55:54 -05:00
commit f932a998fe
1 changed files with 16 additions and 1 deletions

View File

@ -258,6 +258,15 @@ class ClusterFormationTasks {
// this closure is the actual code to run elasticsearch // this closure is the actual code to run elasticsearch
Closure elasticsearchRunner = { Closure elasticsearchRunner = {
// Command as string for logging
String esCommandString = "Elasticsearch command: ${executable} "
esCommandString += (esArgs + esProps).join(' ')
if (esEnv.isEmpty() == false) {
esCommandString += '\nenvironment:'
esEnv.each { k, v -> esCommandString += "\n ${k}: ${v}" }
}
logger.info(esCommandString)
ByteArrayOutputStream buffer = new ByteArrayOutputStream() ByteArrayOutputStream buffer = new ByteArrayOutputStream()
if (logger.isInfoEnabled() || config.daemonize == false) { if (logger.isInfoEnabled() || config.daemonize == false) {
// run with piping streams directly out (even stderr to stdout since gradle would capture it) // run with piping streams directly out (even stderr to stdout since gradle would capture it)
@ -275,11 +284,17 @@ class ClusterFormationTasks {
File logFile = new File(home, "logs/${clusterName}.log") File logFile = new File(home, "logs/${clusterName}.log")
if (logFile.exists()) { if (logFile.exists()) {
logFile.eachLine { line -> logger.error(line) } logFile.eachLine { line -> logger.error(line) }
} else {
logger.error("Couldn't start elasticsearch and couldn't find ${logFile}")
}
if (logger.isInfoEnabled() == false) {
// We already log the command at info level. No need to do it twice.
logger.error(esCommandString)
} }
throw new GradleException('Failed to start elasticsearch') throw new GradleException('Failed to start elasticsearch')
} }
} }
Task start = project.tasks.create(name: name, type: DefaultTask, dependsOn: setup) Task start = project.tasks.create(name: name, type: DefaultTask, dependsOn: setup)
start.doLast(elasticsearchRunner) start.doLast(elasticsearchRunner)
return start return start