# Set to True if verbose log desired debug = False # Detect if another instance is running def exit_if_running(pid): log.debug("Checking if process %d is still alive" % (pid, )) try: os.kill(pid, 0) # If we reached here, there is another process in progress log.debug("Process %d still working, quitting" % (pid, )) sys.exit(0) except OSError: log.debug("Process %d gone" % (pid, )) appPool.hook_tool_run('autorepl') MNTLOCK = mntlock() mypid = os.getpid() templog = '/tmp/repl-%d' % (mypid) now = datetime.datetime.now().replace(microsecond=0) if now.second < 30 or now.minute == 59: now = now.replace(second=0) else: now = now.replace(minute=now.minute + 1, second=0) now = datetime.time(now.hour, now.minute) # (mis)use MNTLOCK as PIDFILE lock. locked = True
# Detect if another instance is running def exit_if_running(pid): if 'AUTOREPL_SKIP_RUNNING' in os.environ: log.debug('Skipping check if autorepl is running.') return log.debug("Checking if process %d is still alive" % (pid, )) try: os.kill(pid, 0) # If we reached here, there is another process in progress log.debug("Process %d still working, quitting" % (pid, )) sys.exit(0) except OSError: log.debug("Process %d gone" % (pid, )) appPool.hook_tool_run('autorepl') MNTLOCK = mntlock() mypid = os.getpid() templog = '/tmp/repl-%d' % (mypid) start = datetime.datetime.now().replace(microsecond=0) if start.second < 30 or start.minute == 59: now = start.replace(second=0) else: now = start.replace(minute=start.minute + 1, second=0) now = datetime.time(now.hour, now.minute) # (mis)use MNTLOCK as PIDFILE lock. locked = True
# Set to True if verbose log desired debug = False # Detect if another instance is running def exit_if_running(pid): log.debug("Checking if process %d is still alive" % (pid,)) try: os.kill(pid, 0) # If we reached here, there is another process in progress log.debug("Process %d still working, quitting" % (pid,)) sys.exit(0) except OSError: log.debug("Process %d gone" % (pid,)) appPool.hook_tool_run("autorepl") MNTLOCK = mntlock() mypid = os.getpid() templog = "/tmp/repl-%d" % (mypid) now = datetime.datetime.now().replace(microsecond=0) if now.second < 30 or now.minute == 59: now = now.replace(second=0) else: now = now.replace(minute=now.minute + 1, second=0) now = datetime.time(now.hour, now.minute) # (mis)use MNTLOCK as PIDFILE lock. locked = True
return True return False # Detect if another instance is running def exit_if_running(pid): log.debug("Checking if process %d is still alive", pid) try: os.kill(pid, 0) # If we reached here, there is another process in progress log.debug("Process %d still working, quitting", pid) sys.exit(0) except OSError: log.debug("Process %d gone", pid) appPool.hook_tool_run('autosnap') mypid = os.getpid() # (mis)use MNTLOCK as PIDFILE lock. locked = True try: MNTLOCK.lock_try() except IOError: locked = False if not locked: sys.exit(0) AUTOSNAP_PID = -1 try: with open('/var/run/autosnap.pid') as pidfile: