clortho

A very simple key/value server
git clone https://www.brianlane.com/git/clortho
Log | Files | Refs | README | LICENSE

commit b3420051be2418edcae1cdb7e62a8379ec85deec
parent 5e190dfbde959604e6341d10a76f3df942c33edb
Author: Brian C. Lane <bcl@redhat.com>
Date:   Thu, 22 Jan 2015 20:02:18 -0800

Save keystore on USR1 signal

Diffstat:
Msrc/clortho.py | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/clortho.py b/src/clortho.py @@ -121,6 +121,11 @@ def read_keystore(filename): except EOFError: keystore = {} +@asyncio.coroutine +def handle_usr1(): + print("Got USR1 signal, saving keystore") + save_keystore(args.keystore) + def save_keystore(filename): #TODO: Write to a tempfile first, rename to target with open(filename, "wb") as f: @@ -134,5 +139,7 @@ if __name__=='__main__': loop = asyncio.get_event_loop() for signame in ('SIGINT', 'SIGTERM'): loop.add_signal_handler(getattr(signal, signame), asyncio.async, clean_exit(signame)) + loop.add_signal_handler(getattr(signal, 'SIGUSR1'), asyncio.async, handle_usr1()) + loop.run_until_complete(init(loop, args.host, int(args.port))) loop.run_forever()