From ef72e885d74ce375eab83df4fceceb97bfcd0333 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Mon, 24 Jul 2023 05:41:47 -0600 Subject: [PATCH] Implement --stay-attached --- app/deploy.py | 4 ++-- app/deployment.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/deploy.py b/app/deploy.py index 41af70f6..4ddd81a7 100644 --- a/app/deploy.py +++ b/app/deploy.py @@ -61,7 +61,7 @@ def create_deploy_context(global_context, stack, include, exclude, cluster, env_ return DeployCommandContext(cluster_context, docker) -def up_operation(ctx, services_list): +def up_operation(ctx, services_list, stay_attached=False): global_context = ctx.parent.parent.obj deploy_context = ctx.obj if not global_context.dry_run: @@ -73,7 +73,7 @@ def up_operation(ctx, services_list): print(f"Running compose up with container_exec_env: {container_exec_env}, extra_args: {services_list}") for pre_start_command in cluster_context.pre_start_commands: _run_command(global_context, cluster_context.cluster, pre_start_command) - deploy_context.docker.compose.up(detach=True, services=services_list) + deploy_context.docker.compose.up(detach=not stay_attached, services=services_list) for post_start_command in cluster_context.post_start_commands: _run_command(global_context, cluster_context.cluster, post_start_command) _orchestrate_cluster_config(global_context, cluster_context.config, deploy_context.docker, container_exec_env) diff --git a/app/deployment.py b/app/deployment.py index e876b77e..132568ca 100644 --- a/app/deployment.py +++ b/app/deployment.py @@ -54,22 +54,24 @@ def make_deploy_context(ctx): @command.command() +@click.option("--stay-attached/--detatch-terminal", default=False, help="detatch or not to see container stdout") @click.argument('extra_args', nargs=-1) # help: command: up @click.pass_context -def up(ctx, extra_args): +def up(ctx, stay_attached, extra_args): ctx.obj = make_deploy_context(ctx) services_list = list(extra_args) or None - up_operation(ctx, services_list) + up_operation(ctx, services_list, stay_attached) # start is the preferred alias for up @command.command() +@click.option("--stay-attached/--detatch-terminal", default=False, help="detatch or not to see container stdout") @click.argument('extra_args', nargs=-1) # help: command: up @click.pass_context -def start(ctx, extra_args): +def start(ctx, stay_attached, extra_args): ctx.obj = make_deploy_context(ctx) services_list = list(extra_args) or None - up_operation(ctx, services_list) + up_operation(ctx, services_list, stay_attached) @command.command()