Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
[COOK-3805] Raise an exception if supervisorctl status output not rec…
Browse files Browse the repository at this point in the history
…ognized.

Signed-off-by: Sean OMeara <someara@opscode.com>
  • Loading branch information
cjerdonek authored and Sean OMeara committed Nov 5, 2013
1 parent 2c31aac commit 9cd5cac
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions providers/service.rb
Expand Up @@ -124,11 +124,18 @@ def cmd_line_args
end

def get_current_state(service_name)
result = Mixlib::ShellOut.new("supervisorctl status #{service_name}").run_command
if result.stdout.include? "No such process #{service_name}"
cmd = "supervisorctl status #{service_name}"
result = Mixlib::ShellOut.new(cmd).run_command
stdout = result.stdout
if stdout.include? "No such process #{service_name}"
"UNAVAILABLE"
else
result.stdout.match("(^#{service_name}\\s*)([A-Z]+)(.+)")[2]
match = stdout.match("(^#{service_name}\\s*)([A-Z]+)(.+)")
if match.nil?
raise "The supervisor service is not running as expected. " \
"The command '#{cmd}' output:\n----\n#{stdout}\n----"
end
match[2]
end
end

Expand Down

0 comments on commit 9cd5cac

Please sign in to comment.