Permalink
Browse files

ensure es starts on reboot

  • Loading branch information...
1 parent 24669a3 commit 0d859340bb2097c7572bbc17e0cd9fd8e8c27461 Chris hunter committed Jun 7, 2011
Showing with 74 additions and 7 deletions.
  1. +23 −7 manifests/init.pp
  2. +3 −0 templates/elasticsearch.limits.conf.erb
  3. +48 −0 templates/upstart.elasticsearch.conf.erb
View
@@ -5,7 +5,7 @@
# Usage:
# include elasticsearch
-class elasticsearch($version = "0.15.2", $xmx = "2048") {
+class elasticsearch($version = "0.15.2", $xmx = "2048m") {
$esBasename = "elasticsearch"
$esName = "${esBasename}-${version}"
$esFile = "${esName}.tar.gz"
@@ -14,13 +14,19 @@
$esPath = "${ebs1}/usr/local/${esName}"
$esPathLink = "/usr/local/${esBasename}"
$esDataPath = "${ebs1}/var/lib/${esBasename}"
+ $esLibPath = "${esDataPath}"
$esLogPath = "${ebs1}/var/log/${esBasename}"
- $esXms = "256"
+ $esXms = "256m"
$esXmx = "${xmx}"
$cluster = "${esBasename}"
$esTCPPortRange = "9300-9399"
$esHTTPPortRange = "9200-9299"
-
+ $esUlimitNofile = "32000"
+ $esUlimitMemlock = "unlimited"
+ $esPidpath = "/var/run"
+ $esPidfile = "${esPidpath}/${esBasename}.pid"
+ $esJarfile = "${esName}.jar"
+
# Ensure the elasticsearch user is present
user { "$esBasename":
ensure => "present",
@@ -31,11 +37,20 @@
uid => 901
}
- # Set this users file handle limits (ES uses a shit ton of file handles)
- file { "/etc/security/limits.conf":
- source => "puppet:///elasticsearch/limits.conf",
- require => user["$esBasename"]
+ file { "/etc/security/limits.d/${esBasename}.conf":
+ content => template("elasticsearch/elasticsearch.limits.conf.erb"),
+ ensure => present,
+ owner => root,
+ group => root,
}
+
+# file { "/etc/init/${esBasename}.conf":
+# content => template("elasticsearch/upstart.elasticsearch.conf.erb"),
+# ensure => present,
+# owner => root,
+# group => root,
+# mode => 644
+# }
exec { "mkdir-ebs-mongohome":
path => "/bin:/usr/bin",
@@ -190,6 +205,7 @@
# Ensure the service is running
service { "$esBasename":
+ enable => true,
ensure => running,
hasrestart => true,
require => File["$esPath/logs"]
@@ -0,0 +1,3 @@
+<%= esBasename %> - nofile <%= esUlimitNofile %>
+<%= esBasename %> - memlock <%= esUlimitMemlock %>
+<%= esBasename %> - core 0
@@ -0,0 +1,48 @@
+# managed by puppet!
+
+start on startup
+start on runlevel [2345]
+stop on runlevel [06]
+
+env ES_HOME=<%= esPath %>
+env ES_CLASSPATH=<%= esJarfile -%>:<%= esLibPath -%>/*
+
+script
+ JAVA=<%= jre6JavaHome %>
+
+ JAVA_OPTS="$JAVA_OPTS -Xms<%= esXms %>"
+ JAVA_OPTS="$JAVA_OPTS -Xmx<%= esXmx %>"
+
+ # reduce the per-thread stack size
+ JAVA_OPTS="$JAVA_OPTS -Xss128k"
+
+ JAVA_OPTS="$JAVA_OPTS -Djline.enabled=true"
+
+ # Enable reference compression, reducing memory overhead on 64bit JVMs
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops"
+
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseParNewGC"
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"
+ JAVA_OPTS="$JAVA_OPTS -XX:+CMSParallelRemarkEnabled"
+ JAVA_OPTS="$JAVA_OPTS -XX:SurvivorRatio=8"
+ JAVA_OPTS="$JAVA_OPTS -XX:MaxTenuringThreshold=1"
+ JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75"
+ JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"
+
+ # GC logging options -- uncomment to enable
+ # JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
+ # JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCTimeStamps"
+ # JAVA_OPTS="$JAVA_OPTS -XX:+PrintClassHistogram"
+ # JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution"
+ # JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime"
+ # JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/elasticsearch/gc.log"
+
+ # Causes the JVM to dump its heap on OutOfMemory.
+ #JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"
+ # The path to the heap dump location, note directory must exists and have enough
+ # space for a full heap dump.
+ #JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$ES_HOME/logs/heapdump.hprof"
+
+ es_parms="-Delasticsearch -Des.path.home=$ES_HOME -Des-pidfile=<%= esPidfile %> -Des-daemon=yes"
+ start-stop-daemon --start --quiet --pidfile <%= esPidfile %> --chdir <%= esPath %> --chuid <%= esBasename %>:<% esBasename %> --exec $JAVA -- $JAVA_OPTS $es_parms -cp $ES_CLASSPATH org.elasticsearch.bootstrap.ElasticSearch
+end script

0 comments on commit 0d85934

Please sign in to comment.