From 6a327ad7f147618a0420f62cd6f73adff24383aa Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Fri, 22 Aug 2014 08:47:49 +0200 Subject: [PATCH] MT#7533 stop rate-o-mat service pid_wached.py: add services that should to stop too --- bin/config_debug.pl | 1 + bin/pid_watcher.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/config_debug.pl b/bin/config_debug.pl index 79ee383b..aa335375 100755 --- a/bin/config_debug.pl +++ b/bin/config_debug.pl @@ -95,6 +95,7 @@ else $yaml->[0]->{kamailio}{proxy}{presence}{enable} = 'yes'; $yaml->[0]->{sems}{debug} = 'yes'; $yaml->[0]->{checktools}{sip_check_enable} = 0; + $yaml->[0]->{rateomat}{enable} = 'no'; tie @array, 'Tie::File', '/etc/hosts' or die ('Can set test domain on /etc/hosts'); for (@array) diff --git a/bin/pid_watcher.py b/bin/pid_watcher.py index 9335e25b..ff8c55ac 100755 --- a/bin/pid_watcher.py +++ b/bin/pid_watcher.py @@ -34,6 +34,10 @@ services = [ 'collectdmon.pid' ] +services_stop = [ + 'rate-o-mat.pid', +] + watched_dirs = [ '/var/run/kamailio', '/var/run/ngcp-sems', @@ -49,7 +53,7 @@ class Handler(pyinotify.ProcessEvent): def check_all(self): all = True for k,v in self.watched.iteritems(): - all = (all and (v['created'] or v['modified'])) + all = (all and (v['created'] or v['modified'] or v['deleted'])) print "checking: %s[%s] all:%s" % (k,v, all) return all @@ -69,6 +73,11 @@ class Handler(pyinotify.ProcessEvent): if watched.has_key(event.pathname): watched[event.pathname]['modified'] = True print "modified %s" % event.pathname + + def process_IN_DELETE(self, event): + if watched.has_key(event.pathname+'_del'): + watched[event.pathname+'_del']['deleted'] = True + print "deleted %s" % event.pathname # for debug # def process_default(self, event): # if watched.has_key(event.pathname): @@ -82,6 +91,13 @@ for service in services: print "Watching %s" % service_pid watched[service_pid] = {'deleted': False, 'created': False, 'modified': False } wm.add_watch(service_pid, pyinotify.IN_IGNORED) + +for service in services_stop: + service_pid = os.path.join(base_path, service) + print "Watching %s" % service_pid + watched[service_pid+'_del'] = {'deleted': False, 'created': False, 'modified': False } + wm.add_watch(service_pid, pyinotify.IN_IGNORED) + for d in watched_dirs: wm.add_watch(d, pyinotify.ALL_EVENTS)