Skip to content

Commit

Permalink
Renamed and updated the file with environment variables for Elasticse…
Browse files Browse the repository at this point in the history
…arch

I haven't yet found a way how to get rid of this file completely, so
I've just renamed it to be consistent with the core file, and updated
the content (removed JMX related settings, added one missing setting from the core file).

Related: #320
  • Loading branch information
karmi committed Jun 23, 2015
1 parent 904133b commit ad6f98a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 35 deletions.
4 changes: 2 additions & 2 deletions libraries/provider_configure.rb
Expand Up @@ -32,8 +32,8 @@ def action_manage
end
end

template "elasticsearch-env.sh" do
path "#{new_resource.path_conf}/elasticsearch-env.sh"
template "elasticsearch.in.sh" do
path "#{new_resource.path_conf}/elasticsearch.in.sh"
source new_resource.template_elasticsearch_env
cookbook 'elasticsearch'
owner new_resource.user
Expand Down
3 changes: 2 additions & 1 deletion libraries/resource_configure.rb
Expand Up @@ -18,7 +18,7 @@ class Resource::ElasticsearchConfigure < Resource
attribute(:user, kind_of: String, default: 'elasticsearch')
attribute(:group, kind_of: String, default: 'elasticsearch')

attribute(:template_elasticsearch_env, kind_of: String, default: 'elasticsearch-env.sh.erb')
attribute(:template_elasticsearch_env, kind_of: String, default: 'elasticsearch.in.sh.erb')
attribute(:template_elasticsearch_yml, kind_of: String, default: 'elasticsearch.yml.erb')
attribute(:template_logging_yml, kind_of: String, default: 'logging.yml.erb')

Expand All @@ -37,6 +37,7 @@ class Resource::ElasticsearchConfigure < Resource
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+HeapDumpOnOutOfMemoryError
-XX:+DisableExplicitGC
CONFIG
)

Expand Down
26 changes: 0 additions & 26 deletions templates/default/elasticsearch-env.sh.erb

This file was deleted.

26 changes: 26 additions & 0 deletions templates/default/elasticsearch.in.sh.erb
@@ -0,0 +1,26 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# THIS FILE IS MANAGED BY CHEF, DO NOT EDIT MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN!
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Environment configuration
# See <https://github.com/elastic/elasticsearch/blob/master/core/bin/elasticsearch.in.sh>
#

<%= "JAVA_HOME='#{@java_home}'\n" if @java_home -%>
ES_HOME='<%= "#{@es_home}/elasticsearch" %>'
ES_CLASSPATH=$ES_CLASSPATH:$ES_HOME/lib/*:$ES_HOME/lib/sigar/*
ES_HEAP_SIZE=<%= @allocated_memory %>

ES_JAVA_OPTS="
-server
-Djava.awt.headless=true
-Djava.net.preferIPv4Stack=true
-Des.config=<%= @es_config %>/elasticsearch.yml
-Xms<%= @Xms %>
-Xmx<%= @Xmx %>
-Xss<%= @Xss %>
<%= @gc_settings %>
-Dfile.encoding=UTF-8
-Djna.nosys=true
<%= @env_options %>
"
2 changes: 1 addition & 1 deletion templates/default/elasticsearch.init.erb
Expand Up @@ -33,7 +33,7 @@ ulimit -l <%= @memlock_limit %>
[ "$NETWORKING" = "no" ] && exit

PIDFILE='<%= @pid_file %>'
ES_INCLUDE='<%= @path_conf %>/elasticsearch-env.sh'
ES_INCLUDE='<%= @path_conf %>/elasticsearch.in.sh'
CHECK_PID_RUNNING=$(ps ax | grep 'java' | grep -e "es.pidfile=$PIDFILE" | sed 's/^\s*\([0-9]*\)\s.*/\1/')

start() {
Expand Down
3 changes: 0 additions & 3 deletions test/fixtures/cookbooks/elasticsearch_test/recipes/default.rb
Expand Up @@ -35,9 +35,6 @@
group 'bar'
logging({:"action" => 'INFO'})

java_rmi_server_hostname 'localhost'
jmx true

allocated_memory '123m'
thread_stack_size '512k'

Expand Down
2 changes: 1 addition & 1 deletion test/integration/default/serverspec/configure_spec.rb
Expand Up @@ -15,7 +15,7 @@
end
end

describe file('/usr/local/etc/elasticsearch/elasticsearch-env.sh') do
describe file('/usr/local/etc/elasticsearch/elasticsearch.in.sh') do
it { should be_file }
it { should be_owned_by 'elasticsearch' }
it { should be_grouped_into 'elasticsearch' }
Expand Down
Expand Up @@ -15,7 +15,7 @@
end
end

describe file('/usr/local/awesome/etc/elasticsearch/elasticsearch-env.sh') do
describe file('/usr/local/awesome/etc/elasticsearch/elasticsearch.in.sh') do
it { should be_file }
it { should be_owned_by 'foo' }
it { should be_grouped_into 'bar' }
Expand Down

0 comments on commit ad6f98a

Please sign in to comment.