commit bc9acae758a8e84c15032d635d37c0917911bc48
parent b3420051be2418edcae1cdb7e62a8379ec85deec
Author: Brian C. Lane <bcl@redhat.com>
Date: Thu, 22 Jan 2015 20:30:12 -0800
Save the keystore every hour
Diffstat:
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/clortho.py b/src/clortho.py
@@ -126,6 +126,10 @@ def handle_usr1():
print("Got USR1 signal, saving keystore")
save_keystore(args.keystore)
+def hourly_save_keystore(loop):
+ save_keystore(args.keystore)
+ loop.call_later(3600, hourly_save_keystore, loop)
+
def save_keystore(filename):
#TODO: Write to a tempfile first, rename to target
with open(filename, "wb") as f:
@@ -141,5 +145,8 @@ if __name__=='__main__':
loop.add_signal_handler(getattr(signal, signame), asyncio.async, clean_exit(signame))
loop.add_signal_handler(getattr(signal, 'SIGUSR1'), asyncio.async, handle_usr1())
+ # Start saving the keys every hour
+ loop.call_later(3600, hourly_save_keystore, loop)
+
loop.run_until_complete(init(loop, args.host, int(args.port)))
loop.run_forever()