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

Fixes start_program/stop_program being malformed #46

Merged
merged 1 commit into from
Nov 5, 2014
Merged
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
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