Skip to content

Commit

Permalink
Merge pull request #52 from goncalopereira/master
Browse files Browse the repository at this point in the history
GOMAXPROCS picks number of CPUs using sysconfig - Also updated Serverspec to 2.0
  • Loading branch information
johnbellone committed Oct 25, 2014
2 parents 553d25f + 6adbdcf commit 31e7357
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
# UI attributes
default['consul']['client_addr'] = '0.0.0.0'
default['consul']['ui_dir'] = '/var/lib/consul/ui'
default['consul']['serve_ui'] = false
default['consul']['serve_ui'] = false
5 changes: 5 additions & 0 deletions recipes/_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@

case node['consul']['init_style']
when 'init'
template '/etc/sysconfig/consul' do
source 'consul-sysconfig.erb'
mode 0755
notifies :create, 'template[/etc/init.d/consul]', :immediately
end
template '/etc/init.d/consul' do
source 'consul-init.erb'
mode 0755
Expand Down
8 changes: 8 additions & 0 deletions spec/unit/recipes/_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
.with(group: 'root')
.with(mode: 0600)
end
it do
expect(chef_run).to create_template('/etc/sysconfig/consul')
.with(source: 'consul-sysconfig.erb')
.with(mode: 0755)
end
it do
expect(chef_run).to render_file('/etc/sysconfig/consul').with_content('GOMAXPROCS=1')
end
it do
expect(chef_run).to create_template('/etc/init.d/consul')
.with(source: 'consul-init.erb')
Expand Down
6 changes: 6 additions & 0 deletions spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'serverspec'
set :backend, :exec

RSpec.configure do |c|
c.path = '/usr/local/bin:/sbin:/bin:/usr/bin'
end
6 changes: 6 additions & 0 deletions templates/default/consul-init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
# * Multi Datacenter
### END INIT INFO

if [ -f /etc/sysconfig/consul ]; then
. /etc/sysconfig/consul
fi

export GOMAXPROCS=${GOMAXPROCS}

CMD="<%= @consul_binary %> agent -config-dir <%= @config_dir %>"
NAME="consul"

Expand Down
1 change: 1 addition & 0 deletions templates/default/consul-sysconfig.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GOMAXPROCS=<%= node['cpu']['total'] %>
2 changes: 0 additions & 2 deletions test/integration/default/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require 'serverspec'

set :backend, :exec

RSpec.configure do |c|
c.path = '/usr/local/bin:/sbin:/bin:/usr/bin'
end
2 changes: 1 addition & 1 deletion test/integration/ui/serverspec/localhost/consul_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe file('/var/lib/consul/ui/index.html') do
describe file('/var/lib/consul/ui/consul_ui/index.html') do
it { should be_file }
end

Expand Down

0 comments on commit 31e7357

Please sign in to comment.