Esempio n. 1
0
 def process(self):
     """@return L{IKittProcess} provider"""
     #work around constructor and allow a process to appear to die
     if not hasattr(self, '_process'):
         #adapt this model to a IKittProcess
         self._process = IKittProcess(self)
     elif self._process.pid != self.pid or not self._process.running:
         if config.HOSTNAME == self.server.hostname:
             AppProcess.delete(
                 self)  #take ourself out of serialization loop
             self._process = IKittNullProcess(
                 self)  #continue to work for any other refs
     return self._process
Esempio n. 2
0
    def process(self):
        """The process object contained by this application instance

           @raise InvalidProcess
           @return (instance of AppProcess)
        """
        if not hasattr(self, '_process'):
            #try to grab a live process, on exception grab a NullProcess
            try:
                assert self.pid  #save the scan attempt
                self._process = IDroneModelAppProcess(self)
            except:
                self._process = IKittNullProcess(
                    self)  #should be a NullProcess
        elif IDroneModelAppProcess.providedBy(self._process) and not \
                AppProcess.isValid(self._process):
            self._process = IKittNullProcess(self)
        #keep the journal up to date
        self.info.update({
            'pid': self._process.pid,
            'inode': self._process.inode,
        })
        return self._process
Esempio n. 3
0
    def children(self):
        """emits a generator of our child process objects

           this is only really useful for scab detection
           this only works if the child pid has been contained
           in another AppProcess Instance. Of course it could
           also be useful in bizarre situations with apps that
           have a parent supervisor and child worker.
        """
        for process in AppProcess.objects:
            if IKittNullProcess.providedBy(process.process): continue
            if not self.pid: break
            if process == self: continue
            if process.server.hostname != self.server.hostname: continue
            if process.ppid == self.pid and AppProcess.isValid(process):
                yield process
Esempio n. 4
0
    def children(self):
        """emits a generator of our child process objects

           this is only really useful for scab detection
           this only works if the child pid has been contained
           in another AppProcess Instance. Of course it could
           also be useful in bizarre situations with apps that
           have a parent supervisor and child worker.
        """
        for process in AppProcess.objects:
            if IKittNullProcess.providedBy(process.process): continue
            if not self.pid: break
            if process == self: continue
            if process.server.hostname != self.server.hostname: continue
            if process.ppid == self.pid and AppProcess.isValid(process):
                yield process
Esempio n. 5
0
 def __init__(self, server, pid):
     self._pid = pid
     self.server = IDroneModelServer(server)
     self._created = time.time()
     #don't set self._process
     try:
         try: #re-constructing, can cause problems with this
             if IKittNullProcess.providedBy(self.process.process):
                 raise InvalidProcess("Invalid PID (%s)" % pid)
         except AttributeError:
             if isinstance(self.process, NullProcess):
                 raise InvalidProcess("Invalid PID (%s)" % pid)
             raise #re-raise do avoid ending up in a pickle, literally
     except InvalidProcess:
         AppProcess.delete(self) #make sure we are invalid
         raise InvalidProcess("Invalid PID (%s)" % pid)
     except IOError: #linux and solaris kitt.proc.LiveProcess use files
         AppProcess.delete(self) #make sure we are invalid
         raise InvalidProcess("Invalid PID (%s)" % pid)
     except:
         err('wtf happened here .. seriously i do not know!!!')
         AppProcess.delete(self) #make sure we are invalid
         raise
Esempio n. 6
0
 def __init__(self, server, pid):
     self._pid = pid
     self.server = IDroneModelServer(server)
     self._created = time.time()
     #don't set self._process
     try:
         try:  #re-constructing, can cause problems with this
             if IKittNullProcess.providedBy(self.process.process):
                 raise InvalidProcess("Invalid PID (%s)" % pid)
         except AttributeError:
             if isinstance(self.process, NullProcess):
                 raise InvalidProcess("Invalid PID (%s)" % pid)
             raise  #re-raise do avoid ending up in a pickle, literally
     except InvalidProcess:
         if config.HOSTNAME == self.server.hostname:
             AppProcess.delete(self)  #make sure we are invalid
             raise InvalidProcess("Invalid PID (%s)" % pid)
     except IOError:  #linux and solaris kitt.proc.LiveProcess use files
         AppProcess.delete(self)  #make sure we are invalid
         raise InvalidProcess("Invalid PID (%s)" % pid)
     except:
         err('wtf happened here .. seriously i do not know!!!')
         AppProcess.delete(self)  #make sure we are invalid
         raise