Skip to content

Commit

Permalink
Fixes start_program/stop_program being malformed
Browse files Browse the repository at this point in the history
3fcbfa5 introduced bug whereby service_bin, script_name, start_cmd and
stop_cmd must be explicitly specified by the resource.

This commit requires a resource to specify a script_name otherwise
start_program and stop_program supplied to the template are "".

Issue rcbops/chef-cookbooks#972
Issue rcbops/chef-cookbooks#860
  • Loading branch information
git-harry committed Oct 27, 2014
1 parent bb9bbb7 commit 98e2e5c
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions providers/procmon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,42 @@
end

action :add do
# use default service_bin for the platform if it has not been
# set in the provider call
if not @new_resource.service_bin.nil?
service_bin = new_resource.service_bin
else
service_bin = node["monit"]["service_bin"]
end

# if script_name was not set then default it to ""
if not @new_resource.script_name.nil?
script_name = new_resource.script_name
else
if @new_resource.script_name.nil? or @new_resource.script_name == ""
service_bin = ""
script_name = ""
end

# if start_cmd is not defined default to 'start'
if not @new_resource.start_cmd.nil?
start_cmd = new_resource.start_cmd
start_cmd = ""
stop_cmd = ""
else
start_cmd = "start"
end
script_name = new_resource.script_name
# use default service_bin for the platform if it has not been
# set in the provider call
if not @new_resource.service_bin.nil?
service_bin = new_resource.service_bin
else
service_bin = node["monit"]["service_bin"]
end

# if start_cmd is not defined default to 'start'
if not @new_resource.stop_cmd.nil?
stop_cmd = new_resource.stop_cmd
else
stop_cmd = "stop"
# if script_name was not set then default it to ""
if not @new_resource.script_name.nil?
script_name = new_resource.script_name
else
script_name = ""
end

# if start_cmd is not defined default to 'start'
if not @new_resource.start_cmd.nil?
start_cmd = new_resource.start_cmd
else
start_cmd = "start"
end

# if start_cmd is not defined default to 'start'
if not @new_resource.stop_cmd.nil?
stop_cmd = new_resource.stop_cmd
else
stop_cmd = "stop"
end
end

http_checks = ensure_array(new_resource.http_check).compact.map do |check|
Expand All @@ -69,13 +78,9 @@
"identifier" => new_resource.name,
"process_name" => new_resource.process_name,
"pid_file" => new_resource.pid_file,
"script_name" => script_name,
"service_bin" => service_bin,
"stop_cmd" => stop_cmd,
"start_cmd" => start_cmd,
"http_checks" => http_checks.sort,
"start_program" => "#{new_resource.service_bin} #{new_resource.script_name} #{new_resource.start_cmd}".strip,
"stop_program" => "#{new_resource.service_bin} #{new_resource.script_name} #{new_resource.stop_cmd}".strip
"start_program" => "#{service_bin} #{script_name} #{start_cmd}".strip,
"stop_program" => "#{service_bin} #{script_name} #{stop_cmd}".strip
)
action :create
notifies :restart, "service[monit]", :delayed
Expand Down

0 comments on commit 98e2e5c

Please sign in to comment.