From 3540627691fc85380858cc8450107ab69351ca73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Wed, 8 Jan 2020 22:26:14 +0100 Subject: [PATCH] Make it possible to run `dev runserver` for any service --- CHANGELOG.md | 1 + tutor/commands/dev.py | 25 +++++++++---------------- tutor/templates/dev/docker-compose.yml | 6 ++++++ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47c788a..faa1b2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥". ## Unreleased +- [Improvement] The `dev runserver` command can now be run for just any service - 💥[Feature] `dev run/exec` commands now support generic options which are passed to docker-compose. Consequently, defining the `TUTOR_EDX_PLATFORM_PATH` environment variable no longer works. Instead, users are encouraged to explicitely pass the `-v` option or define a command alias. ## 3.9.1 (2020-01-08) diff --git a/tutor/commands/dev.py b/tutor/commands/dev.py index f9de5cf..96bd576 100644 --- a/tutor/commands/dev.py +++ b/tutor/commands/dev.py @@ -31,23 +31,16 @@ def dev(context): help="Run a development server", context_settings={"ignore_unknown_options": True}, ) @click.argument("options", nargs=-1, required=False) -@click.argument("service", type=click.Choice(["lms", "cms"])) +@click.argument("service") def runserver(options, service): - port = 8000 if service == "lms" else 8001 - - fmt.echo_info( - "The {} service will be available at http://localhost:{}".format(service, port) - ) - args = [ - "-p", - "{port}:{port}".format(port=port), - *options, - service, - "./manage.py", - service, - "runserver", - "0.0.0.0:{}".format(port), - ] + if service in ["lms", "cms"]: + port = 8000 if service == "lms" else 8001 + fmt.echo_info( + "The {} service will be available at http://localhost:{}".format( + service, port + ) + ) + args = ["--service-ports", *options, service] compose.run.callback(args) diff --git a/tutor/templates/dev/docker-compose.yml b/tutor/templates/dev/docker-compose.yml index 10ba6fa..73cf09a 100644 --- a/tutor/templates/dev/docker-compose.yml +++ b/tutor/templates/dev/docker-compose.yml @@ -14,8 +14,14 @@ services: lms: <<: *openedx-service + command: ./manage.py lms runserver 0.0.0.0:8000 + ports: + - "8000:8000" cms: <<: *openedx-service + command: ./manage.py cms runserver 0.0.0.0:8000 + ports: + - "8001:8000" lms_worker: <<: *openedx-service cms_worker: