Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set GOMAXPROCS > 1 #118

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
consul-cookbook

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.5
8 changes: 8 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
}
default['consul']['source_revision'] = 'master'

# GOMAXPROCS should be greater than 1, see
# https://groups.google.com/forum/#!topic/consul-tool/qewFEqgAoF8
if node['cpu']['total'] > 1
default['consul']['gomaxprocs'] = node['cpu']['total']

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

else
default['consul']['gomaxprocs'] = 2
end

# Service attributes
default['consul']['service_mode'] = 'bootstrap'
default['consul']['retry_on_join'] = false
Expand Down
11 changes: 11 additions & 0 deletions spec/unit/attributes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,16 @@

context 'sets default attributes' do
it { expect(chef_run.node.consul.base_url).to eq("https://dl.bintray.com/mitchellh/consul/%{version}.zip") }
it { expect(chef_run.node.consul.gomaxprocs).to eq(2) }
end

describe 'allow override of gomaxprocs' do
let(:chef_run) do
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '12.04') do |node|
node.set['consul']['gomaxprocs'] = 8
end.converge(described_recipe)
end

it { expect(chef_run.node.consul.gomaxprocs).to eq(8) }
end
end
4 changes: 2 additions & 2 deletions spec/unit/recipes/_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
.with(mode: 0755)
end
it do
expect(chef_run).to render_file('/etc/sysconfig/consul').with_content('GOMAXPROCS=1')
expect(chef_run).to render_file('/etc/sysconfig/consul').with_content('GOMAXPROCS=2')
end
end

Expand All @@ -59,7 +59,7 @@
.with(mode: 0755)
end
it do
expect(chef_run).to render_file('/etc/default/consul').with_content('GOMAXPROCS=1')
expect(chef_run).to render_file('/etc/default/consul').with_content('GOMAXPROCS=2')
end
end

Expand Down
2 changes: 1 addition & 1 deletion templates/default/consul-sysconfig.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
GOMAXPROCS=<%= node['cpu']['total'] %>
GOMAXPROCS=<%= node['consul']['gomaxprocs'] %>