diff --git a/base.py b/base.py index 6769d7c..de5e51c 100644 --- a/base.py +++ b/base.py @@ -237,7 +237,10 @@ class ServiceManager: for p in procs.get(ins, {}).get(service, []): print_wait = True for action in ('terminate', 'kill'): - getattr(p, action)() # p.terminate or p.kill + try: + getattr(p, action)() # p.terminate or p.kill + except psutil.NoSuchProcess: + continue # already killed for i in range(10): # total 0.1 * 10 * 9 / 2 = 4.5 sec try: p.wait(0.1 * i) @@ -261,6 +264,8 @@ class ServiceManager: def do_stop(self, ins, service=None, *args): self.get_info() + if ins is None: + raise ValueError('use stop all if you really want to stop all') ins_list = self.wildcard(ins) if ins_list is not None: return ins_list