solr: Automatically determine java memory limits

This commit is contained in:
Ossi Salmi 2013-08-30 17:34:21 +03:00
parent 298aee2225
commit e6be930f22
2 changed files with 18 additions and 7 deletions

View file

@ -118,12 +118,12 @@ class solr {
}
file { "/etc/init.d/solr":
ensure => present,
mode => "0755",
owner => "root",
group => "root",
source => "puppet:///modules/solr/solr.init",
notify => Exec["add-service-solr"],
ensure => present,
mode => "0755",
owner => "root",
group => "root",
content => template("solr/solr.init.erb"),
notify => Exec["add-service-solr"],
}
exec { "add-service-solr":
path => "/bin:/usr/bin:/sbin:/usr/sbin",

View file

@ -1,3 +1,14 @@
<%
mem, unit = @memorysize.split
case unit
when "GB"
mem = mem.to_i * 1024
else
mem = mem.to_i
end
heapmin = (mem * 0.15).to_i
heapmax = (mem * 0.85).to_i
-%>
#!/bin/sh
# chkconfig: 2345 95 05
@ -19,7 +30,7 @@ SOLRUSER="solr"
RUNDIR="/srv/solr/run"
HOMEDIR="/srv/solr/cores"
LOG4JCONFIG="file:///${RUNDIR}/resources/log4j.properties"
MEMORYLIMIT="-Xms1024M -Xmx4096M"
MEMORYLIMIT="-Xms<%= heapmin %>M -Xmx<%= heapmax %>M"
if [ `id -u` != "0" ]; then
echo "This script must be run with root privileges." && exit 1