Ejemplo n.º 1
0
 def putpid(cls):
     '''Store current PID to file; should only be called in daemon process.'''
     if LGI.getpid() is not None:
         LGI.pilot.log.warning('daemon already running, not overwriting pid file')
         return False
     f = open(Config.getConfig('LGI')['PidFile'], 'w')
     f.write(str(os.getpid()))
     f.close()
     return True
Ejemplo n.º 2
0
 def getpid(cls):
     '''Return PID of daemon process, if any'''
     # make sure PID file exists
     pidfile = Config.getConfig('LGI')['PidFile']
     if not os.path.exists(pidfile):
         return None
     # get it
     try:
         f = open(pidfile, 'r')
         pid = int(f.read())
         f.close()
     except (OSError, ValueError):
         return None
     # verify it's still running; if not, remove
     try:
         os.kill(pid, 0)
     except OSError:
         os.unlink(pidfile)
         return None
     # ok!
     return pid
Ejemplo n.º 3
0
 def delpid(cls):
     '''Remove current PID file; should only be called at end of daemon process.'''
     os.unlink(Config.getConfig('LGI')['PidFile'])