X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=blobdiff_plain;f=ud-replicated;h=1e19ef4ac0b14470f5d2c19de616391a34e52d33;hp=26f8695eb82d9916a720f5a2e5eca51b86992690;hb=b56535412882ea06155eb3faaaa2357c52a4279e;hpb=e783718da683b5058515ec5a466ae0e530388d19 diff --git a/ud-replicated b/ud-replicated index 26f8695..1e19ef4 100755 --- a/ud-replicated +++ b/ud-replicated @@ -71,9 +71,14 @@ formatter = logging.Formatter(SFORMAT) syslog_handler.setFormatter(formatter) LOG.addHandler(syslog_handler) +last_run = 0 + def do_replicate(message): - last_update = time.time() - LOG.debug("Got message at %s" % last_update) + global last_run + last_update = int(time.time()) + LOG.debug("Got message at %s: %s" % (last_update, message['message'])) + if last_run > message.get('timestamp', 0): + return command = ['/usr/bin/ud-replicate'] if options.dryrun: @@ -89,7 +94,7 @@ def do_replicate(message): LOG.debug('%s finished with ret: 0' % ' '.join(command)) finally: os.environ['TERM'] = old_term - LOG.debug(message) + last_run = int(time.time()) def main(): conn = Connection(conf=mq_conf)