diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2018-10-11 17:03:31 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2018-10-11 17:03:31 +0200 |
commit | 3e69f8b34a48ffa4df4805c53aeaba144d91c6bc (patch) | |
tree | da356cd34700e742b48719ca06a0a392d2363597 /crocoite/cli.py | |
parent | 68c9c012efb84817685a889f100d207cc75fb2c2 (diff) | |
download | crocoite-3e69f8b34a48ffa4df4805c53aeaba144d91c6bc.tar.gz crocoite-3e69f8b34a48ffa4df4805c53aeaba144d91c6bc.tar.bz2 crocoite-3e69f8b34a48ffa4df4805c53aeaba144d91c6bc.zip |
recursive: Gracefully shut down on SIGINT/TERM
Diffstat (limited to 'crocoite/cli.py')
-rw-r--r-- | crocoite/cli.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crocoite/cli.py b/crocoite/cli.py index 0319dc9..55ff4a1 100644 --- a/crocoite/cli.py +++ b/crocoite/cli.py @@ -22,7 +22,7 @@ Command line interface """ -import argparse, json, sys +import argparse, json, sys, signal from . import behavior from .controller import SinglePageController, defaultSettings, \ @@ -104,6 +104,9 @@ def recursive (): concurrency=args.concurrency) loop = asyncio.get_event_loop() + stop = lambda signum: controller.cancel () + loop.add_signal_handler (signal.SIGINT, stop, signal.SIGINT) + loop.add_signal_handler (signal.SIGTERM, stop, signal.SIGTERM) loop.run_until_complete(controller.run ()) loop.close() |