]> git.llucax.com Git - software/pymin.git/blobdiff - pymin/procman.py
Merge branch 'master' of git.llucax.com.ar:/var/lib/git/software/pymin into procman
[software/pymin.git] / pymin / procman.py
index cb00f4ff54647ef66b621251ab36238aaba5aafc..4478cb7c0eff9b7280b1049162fea17e066ff0c6 100644 (file)
@@ -45,7 +45,7 @@ class ProcessInfo:
             self.kill(signal.SIGTERM)
     def kill(self, signum):
         assert self.process is not None
-        os.kill(pi.process.pid, signum)
+        os.kill(self.process.pid, signum)
         self.signal = signum
     def __repr__(self):
         pid = None
@@ -84,7 +84,16 @@ class ProcessManager:
 
     def stop(self, name):
         assert name in self.namemap
-        self.namemap[name].stop(name)
+        self.namemap[name].stop()
+
+    def restart(self, name):
+        logging.debug(u'ProcessManager.restart(%s)', name)
+        if name in self.namemap:
+            self.namemap[name].stop()
+            self.namemap[name].wait()
+            self.namemap[name].restart()
+        else:
+            self.namemap[name].start()
 
     def kill(self, name, signum):
         assert name in self.namemap
@@ -131,7 +140,7 @@ class ProcessManager:
         else: # is a pid
             if name in self.pidmap:
                 return self.pidmap[name]
-        return KeyError, name
+        raise KeyError, name
 
     def has(self, name):
         if isinstance(name, basestring): # is a name
@@ -199,7 +208,7 @@ if __name__ == '__main__':
     while manager.pidmap:
         signal.pause()
         if sig == signal.SIGCHLD:
-            sig = None
             sigchild_handler(sig)
+            sig = None
         print "Esperando...", [pi.name for pi in manager.namemap.values()]