Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

templates should not notifiy statsd service to restart if service att… #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 10 additions & 1 deletion recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@

require 'chef/mixin/deep_merge'

service_status = node['statsd']['service'].map do |a, s|
case a.to_s
when 'enable'
s == false ? :disable : :enable
when 'start'
s == false ? :stop : :start
end
end

backends = []

if node['statsd']['graphite_enabled']
Expand Down Expand Up @@ -73,7 +82,7 @@

Chef::Mixin::DeepMerge.deep_merge!(node['statsd']['extra_config'], config_hash)
variables config_hash: config_hash
notifies :restart, 'service[statsd]', :delayed
notifies :restart, 'service[statsd]', :delayed unless service_status.any? { |x| [:disable, :stop].include?(x) }
end

file node['statsd']['log_file'] do
Expand Down
10 changes: 10 additions & 0 deletions recipes/systemd_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@
# limitations under the License.
#

service_status = node['statsd']['service'].map do |a, s|
case a.to_s
when 'enable'
s == false ? :disable : :enable
when 'start'
s == false ? :stop : :start
end
end

template '/etc/systemd/system/statsd.service' do
source 'systemd.service.erb'
action :create
notifies :restart, 'service[statsd]', :delayed unless service_status.any? { |x| [:disable, :stop].include?(x) }
end

service 'statsd' do
Expand Down
11 changes: 10 additions & 1 deletion recipes/upstart_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@
# limitations under the License.
#

service_status = node['statsd']['service'].map do |a, s|
case a.to_s
when 'enable'
s == false ? :disable : :enable
when 'start'
s == false ? :stop : :start
end
end

# Install our init script.
template '/etc/init/statsd.conf' do
source 'upstart.conf.erb'
mode 0644
notifies :restart, 'service[statsd]', :delayed
notifies :restart, 'service[statsd]', :delayed unless service_status.any? { |x| [:disable, :stop].include?(x) }
end

# Set up our service.
Expand Down