summaryrefslogtreecommitdiff
path: root/crocoite/cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'crocoite/cli.py')
-rw-r--r--crocoite/cli.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/crocoite/cli.py b/crocoite/cli.py
index e4a46ee..390cae6 100644
--- a/crocoite/cli.py
+++ b/crocoite/cli.py
@@ -69,7 +69,11 @@ def single ():
service=service, handler=handler, behavior=b, logger=logger)
try:
loop = asyncio.get_event_loop()
- loop.run_until_complete(controller.run ())
+ run = asyncio.ensure_future (controller.run ())
+ stop = lambda signum: run.cancel ()
+ loop.add_signal_handler (signal.SIGINT, stop, signal.SIGINT)
+ loop.add_signal_handler (signal.SIGTERM, stop, signal.SIGTERM)
+ loop.run_until_complete(run)
loop.close()
ret = SingleExitStatus.Ok
except Crashed: