Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attach container stdin on tutor dev start <service> #1152

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Bugfix] Fix breakpoint debugging by attaching container stdin when running tutor dev start <service> for a single <service>. (by @Danyal-Faheem)
2 changes: 2 additions & 0 deletions docs/tutorials/edx-platform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
10 changes: 9 additions & 1 deletion tutor/commands/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,22 @@ def start(
services: list[str],
) -> None:
command = ["up", "--remove-orphans"]
attach = len(services) == 1
Copy link
Contributor

@regisb regisb Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we can simplify the code slightly by writing:

attach = len(services) == 1 and not detach

Then below:

if detach: 
    command.append("-d")
...
if attach:
    ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great suggestion, I've made the change.

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comment 😂

command.append("-d")

# Start services
config = tutor_config.load(context.root)
context.job_runner(config).docker_compose(*command, *services)
if attach and not detach:
fmt.echo_info(
f"""Attaching to service {services[0]}
Danyal-Faheem marked this conversation as resolved.
Show resolved Hide resolved
ℹ️ 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")
Expand Down
Loading