+ log.debug(u'ProcessManager()')
+
+ def register(self, name, command, callback=None, persist=False,
+ *args, **kw):
+ log.debug(u'ProcessManager.register(%s, %s, %s, %s, %s, %s)',
+ name, command, callback, persist, args, kw)
+ self.services[name] = ProcessInfo(name, command, callback, persist,
+ args, kw)
+
+ def unregister(self, name):
+ log.debug(u'ProcessManager.unregister(%s)', name)
+ del self.services[name]
+
+ def _call(self, pi):
+ pi.start()
+ self.namemap[pi.name] = self.pidmap[pi.process.pid] = pi
+
+ def call(self, name, command, callback=None, persist=False, *args, **kw):
+ log.debug(u'ProcessManager.call(%s, %s, %s, %s, %s, %s)',
+ name, command, callback, persist, args, kw)
+ pi = ProcessInfo(name, command, callback, persist, args, kw)
+ self._call(pi)
+
+ def start(self, name):
+ log.debug(u'ProcessManager.start(%s)', name)
+ assert name not in self.namemap
+ self._call(self.services[name])
+
+ def stop(self, name):
+ log.debug(u'ProcessManager.stop(%s)', name)
+ assert name in self.namemap
+ self.namemap[name].stop()
+
+ def restart(self, name):
+ log.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()