def stop_service
if Win32::Service.exists?(@new_resource.service_name)
if current_state == RUNNING
if @new_resource.stop_command
Chef::Log.debug "#{@new_resource} stopping service using the given stop_command"
shell_out!(@new_resource.stop_command)
else
spawn_command_thread do
Win32::Service.stop(@new_resource.service_name)
wait_for_state(STOPPED)
end
end
@new_resource.updated_by_last_action(true)
else
Chef::Log.debug "#{@new_resource} already stopped - nothing to do"
end
else
Chef::Log.debug "#{@new_resource} does not exist - nothing to do"
end
end