diff --git a/changelog.d/20241205_211837_danyal.faheem_add_dev_attach_command.md b/changelog.d/20241205_211837_danyal.faheem_add_dev_attach_command.md new file mode 100644 index 0000000000..73f6b9f0cc --- /dev/null +++ b/changelog.d/20241205_211837_danyal.faheem_add_dev_attach_command.md @@ -0,0 +1 @@ +- [Bugfix] Fix breakpoint debugging by attaching container stdin when running tutor dev start for a single service. (by @Danyal-Faheem) \ No newline at end of file diff --git a/docs/tutorials/edx-platform.rst b/docs/tutorials/edx-platform.rst index cd66d0893e..a5cd084816 100644 --- a/docs/tutorials/edx-platform.rst +++ b/docs/tutorials/edx-platform.rst @@ -139,6 +139,8 @@ To debug a local edx-platform repository, first, start development in detached m # Or, debugging CMS: tutor dev start cms +To detach from the service without shutting it down, use ``Ctrl+p`` followed with ``Ctrl+q``. + Running edx-platform unit tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tutor/commands/compose.py b/tutor/commands/compose.py index 6c156ff210..c275630c23 100644 --- a/tutor/commands/compose.py +++ b/tutor/commands/compose.py @@ -245,15 +245,26 @@ def start( services: list[str], ) -> None: command = ["up", "--remove-orphans"] + attach = len(services) == 1 and not detach if build: command.append("--build") - if detach: + # We have to run the container in detached mode first to attach to it + if detach or attach: command.append("-d") + else: + fmt.echo_info("ℹ️ To exit logs without stopping the containers, use ctrl+z") # Start services config = tutor_config.load(context.root) context.job_runner(config).docker_compose(*command, *services) + if attach: + fmt.echo_info( + f"""Attaching to service {services[0]} +ℹ️ To detach without stopping the service, use ctrl+p followed by ctrl+q""" + ) + context.job_runner(config).docker_compose("attach", *services) + @click.command(help="Stop a running platform") @click.argument("services", metavar="service", nargs=-1)