mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-06-10 09:42:23 +00:00
cdc221b20e
Override files are not automatically loaded when running with `-f`, so we need to specify them manually.
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
import os
|
|
|
|
import click
|
|
|
|
from . import compose
|
|
from .context import Context
|
|
from .. import env as tutor_env
|
|
from .. import fmt
|
|
from .. import utils
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
class DevContext(Context):
|
|
@staticmethod
|
|
def docker_compose(root, config, *command):
|
|
args = [
|
|
"-f",
|
|
tutor_env.pathjoin(root, "local", "docker-compose.yml"),
|
|
]
|
|
override_path = tutor_env.pathjoin(root, "local", "docker-compose.override.yml")
|
|
if os.path.exists(override_path):
|
|
args += ["-f", override_path]
|
|
args += [
|
|
"-f",
|
|
tutor_env.pathjoin(root, "dev", "docker-compose.yml"),
|
|
]
|
|
override_path = tutor_env.pathjoin(root, "dev", "docker-compose.override.yml")
|
|
if os.path.exists(override_path):
|
|
args += ["-f", override_path]
|
|
return utils.docker_compose(
|
|
*args, "--project-name", config["DEV_PROJECT_NAME"], *command,
|
|
)
|
|
|
|
|
|
@click.group(help="Run Open edX platform with development settings")
|
|
@click.pass_context
|
|
def dev(context):
|
|
context.obj = DevContext(context.obj.root)
|
|
|
|
|
|
@click.command(
|
|
help="Run a development server", context_settings={"ignore_unknown_options": True},
|
|
)
|
|
@click.argument("options", nargs=-1, required=False)
|
|
@click.argument("service")
|
|
def runserver(options, service):
|
|
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)
|
|
|
|
|
|
dev.add_command(runserver)
|
|
compose.add_commands(dev)
|