def determine_current_status!
if @new_resource.status_command
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
begin
if shell_out(@new_resource.status_command).exitstatus == 0
@current_resource.running true
Chef::Log.debug("#{@new_resource} is running")
end
rescue Mixlib::ShellOut::ShellCommandFailed, SystemCallError
@status_load_success = false
@current_resource.running false
nil
end
elsif @new_resource.supports[:status]
Chef::Log.debug("#{@new_resource} supports status, running")
begin
if shell_out("#{@init_command} status").exitstatus == 0
@current_resource.running true
Chef::Log.debug("#{@new_resource} is running")
end
rescue Mixlib::ShellOut::ShellCommandFailed, SystemCallError
@status_load_success = false
@current_resource.running false
nil
end
else
Chef::Log.debug "#{@new_resource} falling back to process table inspection"
r = Regexp.new(@new_resource.pattern)
Chef::Log.debug "#{@new_resource} attempting to match '#{@new_resource.pattern}' (#{r.inspect}) against process list"
begin
shell_out!(ps_cmd).stdout.each_line do |line|
if r.match(line)
@current_resource.running true
break
end
end
@current_resource.running false unless @current_resource.running
Chef::Log.debug "#{@new_resource} running: #{@current_resource.running}"
rescue Mixlib::ShellOut::ShellCommandFailed, SystemCallError
@ps_command_failed = true
end
end
end