From a606a6e5f608b0e35967412f66fc5dfbb6935f07 Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Wed, 4 Oct 2017 13:04:27 -0500 Subject: [PATCH 3/5] Update getpid function Enhance the getpid function to avoid matching with the "puppet apply" command --- lib/puppet/provider/service/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb index 92cc1c3..95814c3 100644 --- a/lib/puppet/provider/service/base.rb +++ b/lib/puppet/provider/service/base.rb @@ -31,6 +31,7 @@ Puppet::Type.type(:service).provide :base, :parent => :service do def getpid @resource.fail "Either stop/status commands or a pattern must be specified" unless @resource[:pattern] regex = Regexp.new(@resource[:pattern]) + regex_pa = Regexp.new('puppet apply') ps = getps self.debug "Executing '#{ps}'" @@ -49,7 +50,7 @@ Puppet::Type.type(:service).provide :base, :parent => :service do table = Puppet::Util::CharacterEncoding.scrub(table) unless table.valid_encoding? table.each_line { |line| - if regex.match(line) + if regex.match(line) and not regex_pa.match(line) self.debug "Process matched: #{line}" ary = line.sub(/^[[:space:]]+/u, '').split(/[[:space:]]+/u) return ary[1] -- 2.16.6