Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ configure(distributions) {
configure(distributions.findAll { ['zip', 'tar', 'integ-test-zip'].contains(it.name) }) {
// CopySpec does not make it easy to create an empty director so we create the directory that we want, and then point CopySpec to its
// parent to copy to the root of the distribution
File logs = new File(buildDir, 'logs-hack/logs')
task createLogDir(type: EmptyDirTask) {
dir "${logs}"
dirMode 0755
}
File plugins = new File(buildDir, 'plugins-hack/plugins')
task createPluginsDir(type: EmptyDirTask) {
dir "${plugins}"
Expand All @@ -247,6 +252,12 @@ configure(distributions.findAll { ['zip', 'tar', 'integ-test-zip'].contains(it.n
MavenFilteringHack.filter(it, expansions)
}
}
into('') {
from {
dirMode 0755
logs.getParent()
}
}
into('') {
from {
dirMode 0755
Expand Down Expand Up @@ -497,7 +508,9 @@ task run(type: RunTask) {
Map<String, String> expansionsForDistribution(distributionType) {
final String defaultHeapSize = "1g"
final String packagingPathData = "path.data: /var/lib/elasticsearch"
final String packagingPathLogs = "path.logs: /var/log/elasticsearch"
final String pathLogs = "/var/log/elasticsearch"
final String packagingPathLogs = "path.logs: ${pathLogs}"
final String packagingLoggc = "${pathLogs}/gc.log"

String footer = "# Built for ${project.name}-${project.version} " +
"(${distributionType})"
Expand Down Expand Up @@ -533,6 +546,11 @@ Map<String, String> expansionsForDistribution(distributionType) {
'rpm': packagingPathLogs,
'def': '#path.logs: /path/to/logs'
],
'loggc': [
'deb': packagingLoggc,
'rpm': packagingLoggc,
'def': 'logs/gc.log'
],

'heap.min': defaultHeapSize,
'heap.max': defaultHeapSize,
Expand Down
2 changes: 1 addition & 1 deletion distribution/integ-test-zip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.elasticsearch.gradle.plugin.PluginBuildPlugin
import org.apache.tools.ant.taskdefs.condition.Os

task buildZip(type: Zip) {
dependsOn createPluginsDir
dependsOn createLogDir, createPluginsDir
baseName = 'elasticsearch'
with archivesFiles
}
Expand Down
1 change: 1 addition & 0 deletions distribution/src/main/resources/bin/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options
JVM_OPTIONS=`parse_jvm_options "$ES_JVM_OPTIONS"`
ES_JAVA_OPTS="${JVM_OPTIONS//\$\{ES_TMPDIR\}/$ES_TMPDIR} $ES_JAVA_OPTS"

cd "$ES_HOME"
# manual parsing to find out, if process should be detached
if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null; then
exec \
Expand Down
1 change: 1 addition & 0 deletions distribution/src/main/resources/bin/elasticsearch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ rem such options are the lines beginning with '-', thus "findstr /b"
for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a
@endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS:${ES_TMPDIR}=!ES_TMPDIR!% %ES_JAVA_OPTS%

cd "%ES_HOME%"
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!

endlocal
Expand Down
25 changes: 8 additions & 17 deletions distribution/src/main/resources/config/jvm.options
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,11 @@ ${heap.dump.path}

## GC logging

#-XX:+PrintGCDetails
#-XX:+PrintGCTimeStamps
#-XX:+PrintGCDateStamps
#-XX:+PrintClassHistogram
#-XX:+PrintTenuringDistribution
#-XX:+PrintGCApplicationStoppedTime

# log GC status to a file with time stamps
# ensure the directory exists
#-Xloggc:${loggc}

# By default, the GC log file will not rotate.
# By uncommenting the lines below, the GC log file
# will be rotated every 128MB at most 32 times.
#-XX:+UseGCLogFileRotation
#-XX:NumberOfGCLogFiles=32
#-XX:GCLogFileSize=128M
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:${loggc}
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=32
-XX:GCLogFileSize=64m
2 changes: 1 addition & 1 deletion distribution/tar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

task buildTar(type: Tar) {
dependsOn createPluginsDir
dependsOn createLogDir, createPluginsDir
baseName = 'elasticsearch'
extension = 'tar.gz'
with archivesFiles
Expand Down
2 changes: 1 addition & 1 deletion distribution/zip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.elasticsearch.gradle.plugin.PluginBuildPlugin

task buildZip(type: Zip) {
dependsOn createPluginsDir
dependsOn createLogDir, createPluginsDir
baseName = 'elasticsearch'
with archivesFiles
}
Expand Down
9 changes: 9 additions & 0 deletions docs/reference/setup/important-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,12 @@ the Elasticsearch process. If you wish to configure a heap dump path, you should
modify the entry `#-XX:HeapDumpPath=/heap/dump/path` in
<<jvm-options,`jvm.options`>> to remove the comment marker `#` and to specify an
actual path.

[float]
[[gc-logging]]
=== GC logging

By default, Elasticsearch enables GC logs. These are configured in
<<jvm-options,`jvm.options`>> and default to the same default location as the
Elasticsearch logs. The default configuration rotates the logs every 64 MB and
can consume up to 2 GB of disk space.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ setup() {
export ES_JAVA_OPTS=$es_java_opts
}

@test "[TAR] GC logs exist" {
start_elasticsearch_service
assert_file_exist $ESHOME/logs/gc.log.0.current
stop_elasticsearch_service
}

@test "[TAR] remove tar" {
rm -rf "/tmp/elasticsearch"
}
6 changes: 6 additions & 0 deletions qa/vagrant/src/test/resources/packaging/tests/60_systemd.bats
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,9 @@ setup() {
[ -d /var/run/elasticsearch ]
systemctl stop elasticsearch.service
}

@test "[SYSTEMD] GC logs exist" {
start_elasticsearch_service
assert_file_exist /var/log/elasticsearch/gc.log.0.current
stop_elasticsearch_service
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,9 @@ setup() {

service elasticsearch stop
}

@test "[INIT.D] GC logs exist" {
start_elasticsearch_service
assert_file_exist /var/log/elasticsearch/gc.log.0.current
stop_elasticsearch_service
}
1 change: 1 addition & 0 deletions qa/vagrant/src/test/resources/packaging/utils/tar.bash
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ verify_archive_installation() {
assert_file "$ESCONFIG/log4j2.properties" f elasticsearch elasticsearch 660
assert_file "$ESPLUGINS" d elasticsearch elasticsearch 755
assert_file "$ESHOME/lib" d elasticsearch elasticsearch 755
assert_file "$ESHOME/logs" d elasticsearch elasticsearch 755
assert_file "$ESHOME/NOTICE.txt" f elasticsearch elasticsearch 644
assert_file "$ESHOME/LICENSE.txt" f elasticsearch elasticsearch 644
assert_file "$ESHOME/README.textile" f elasticsearch elasticsearch 644
Expand Down