From 3712b545a98207adfc07a27b4e7d2607bd23015c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Laurin=20H=C3=B6rmann?= Date: Sun, 24 May 2020 16:09:56 +0200 Subject: [PATCH] ENH: add timeout option to podman-compose down, as in https://docs.docker.com/compose/reference/down/ --- podman_compose.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/podman_compose.py b/podman_compose.py index c062485..448be8f 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -1161,8 +1161,14 @@ def compose_up(compose, args): @cmd_run(podman_compose, 'down', 'tear down entire stack') def compose_down(compose, args): + podman_args=[] + timeout=getattr(args, 'timeout', None) + if timeout is None: + timeout = 1 + podman_args.extend(['-t', "{}".format(timeout)]) + for cnt in compose.containers: - compose.podman.run(["stop", "-t=1", cnt["name"]], sleep=0) + compose.podman.run(["stop", *podman_args, cnt["name"]], sleep=0) for cnt in compose.containers: compose.podman.run(["rm", cnt["name"]], sleep=0) for pod in compose.pods: @@ -1331,7 +1337,7 @@ def compose_run_parse(parser): parser.add_argument('cnt_command', metavar='command', nargs=argparse.REMAINDER, help='command and its arguments') -@cmd_parse(podman_compose, ['stop', 'restart']) +@cmd_parse(podman_compose, ['down', 'stop', 'restart']) def compose_parse_timeout(parser): parser.add_argument("-t", "--timeout", help="Specify a shutdown timeout in seconds. ",