(self)
Stop the daemon.
Stop the daemon.
Stop the daemon .
def stop(self):
        """Stop the daemon."""

        # Get the pid from the pidfile
        try:
            with open(self.pidfile,'r') as pf:
                pid = int(pf.read().strip())
        except IOError:
            pid = None
    
        if not pid:
            message = "pidfile {0} does not exist. " + \
                    "Daemon not running?\n"
            sys.stderr.write(message.format(self.pidfile))
            return # not an error in a restart

        # Try killing the daemon process    
        try:
            while 1:
                os.kill(pid, signal.SIGTERM)
                time.sleep(0.1)
        except OSError as err:
            e = str(err.args)
            if e.find("No such process") > 0:
                if os.path.exists(self.pidfile):
                    os.remove(self.pidfile)
            else:
                print (str(err.args))
                sys.exit(1)
def stop ( self ) : # Get the pid from the pidfile try : with open ( self . pidfile , 'r' ) as pf : pid = int ( pf . read ( ) . strip ( ) ) except IOError : pid = None if not pid : message = "pidfile {0} does not exist. " + "Daemon not running?\n" sys . stderr . write ( message . format ( self . pidfile ) ) return # not an error in a restart # Try killing the daemon process     try : while 1 : os . kill ( pid , signal . SIGTERM ) time . sleep ( 0.1 ) except OSError as err : e = str ( err . args ) if e . find ( "No such process" ) > 0 : if os . path . exists ( self . pidfile ) : os . remove ( self . pidfile ) else : print ( str ( err . args ) ) sys . exit ( 1 )