示例#1
0
 def start(self):
     pid = getPid(self._pidPath)
     if pid is None:
         print 'starting %s' % self._name
         return True
     else:
         print '%s is already running, pid %s' % (self._name, pid)
         return False
示例#2
0
 def stop(self):
     pid = getPid(self._pidPath)
     if pid:
         print ('stopping %s (first attempt, SIGTERM), pid %s...'
                % (self._name, pid))
         os.kill(pid, signal.SIGTERM)
         isDead = waitUntilDead(pid, timeout=10)
         if isDead:
             print 'stopped'
             self.removePid()
             return
         print ('stopping %s (second attempt, SIGKILL), pid %s...'
                % (self._name, pid))
         os.kill(pid, signal.SIGKILL)
         isDead = waitUntilDead(pid, timeout=10)
         if isDead:
             print 'stopped'
             self.removePid()
             return
         print ("can't kill running %s, pid %s"
                % (self._name, pid))
     else:
         print '%s does not appear to be running' % self._name
示例#3
0
 def status(self):
     pid = getPid(self._pidPath)
     if pid is None:
         print '%s is stopped' % self._name
     else:
         print '%s is running, pid %s' % (self._name, pid)