X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-replicated;h=1efbceadaff1e1ec332407ae6f408d540cdf63eb;hb=4b9512d193353298e8d85e6781308dfb2f40d0cd;hp=1e19ef4ac0b14470f5d2c19de616391a34e52d33;hpb=b56535412882ea06155eb3faaaa2357c52a4279e;p=mirror%2Fuserdir-ldap.git diff --git a/ud-replicated b/ud-replicated index 1e19ef4..1efbcea 100755 --- a/ud-replicated +++ b/ud-replicated @@ -76,8 +76,13 @@ last_run = 0 def do_replicate(message): 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): + timestamp = last_update + + if isinstance(message, dict): + timestamp = message.get('timestamp', last_update) + message = message.get('message', 'update required') + LOG.debug("Got message at %s: %s" % (last_update, message)) + if last_run > timestamp, last_update): return command = ['/usr/bin/ud-replicate'] @@ -94,7 +99,7 @@ def do_replicate(message): LOG.debug('%s finished with ret: 0' % ' '.join(command)) finally: os.environ['TERM'] = old_term - last_run = int(time.time()) + last_run = last_update def main(): conn = Connection(conf=mq_conf) @@ -115,5 +120,7 @@ def main(): sys.exit(0) if __name__ == '__main__': - do_replicate('startup complete') + do_replicate( + {'timestamp': time.time(), + 'message': 'startup complete'}) main()