6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 06:07:56 +00:00

Make it possible to start/stop/reboot a selection of services

This commit is contained in:
Régis Behmo 2019-07-09 12:20:06 +08:00
parent eb7037a70f
commit b75d92f88a
3 changed files with 21 additions and 15 deletions

View File

@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".
## Latest
- [Improvement] Make it possible to start/stop/reboot a selection of services
- [Improvement] Add ``local/k8s reboot`` commands
- [Improvement] Add ``-U/--unset`` option to ``config save``
- [Bugfix] Fix insecure static asset loading when web proxy is enabled

View File

@ -21,7 +21,7 @@ def dev():
@opts.edx_platform_settings
@click.argument("service")
@click.argument("command", default=None, required=False)
@click.argument("args", nargs=-1, required=False)
@click.argument("args", nargs=-1)
def run(root, edx_platform_path, edx_platform_settings, service, command, args):
run_command = [service]
if command:

View File

@ -31,7 +31,7 @@ def quickstart(root, non_interactive, pullimages_):
click.echo(fmt.title("Updating the current environment"))
tutor_env.save(root, config)
click.echo(fmt.title("Stopping any existing platform"))
stop.callback(root)
stop.callback(root, [])
if pullimages_:
click.echo(fmt.title("Docker image updates"))
pullimages.callback(root)
@ -40,7 +40,7 @@ def quickstart(root, non_interactive, pullimages_):
click.echo(fmt.title("HTTPS certificates generation"))
https_create.callback(root)
click.echo(fmt.title("Starting the platform in detached mode"))
start.callback(root, True)
start.callback(root, True, [])
@click.command(help="Update docker images")
@ -50,16 +50,17 @@ def pullimages(root):
docker_compose(root, config, "pull")
@click.command(help="Run all configured Open edX services")
@click.command(help="Run all or a selection of configured Open edX services")
@opts.root
@click.option("-d", "--detach", is_flag=True, help="Start in daemon mode")
def start(root, detach):
@click.argument("services", metavar="service", nargs=-1)
def start(root, detach, services):
command = ["up", "--remove-orphans"]
if detach:
command.append("-d")
config = tutor_config.load(root)
docker_compose(root, config, *command)
docker_compose(root, config, *command, *services)
if detach:
fmt.echo_info("The Open edX platform is now running in detached mode")
@ -84,9 +85,10 @@ def start(root, detach):
@click.command(help="Stop a running platform")
@opts.root
def stop(root):
@click.argument("services", metavar="service", nargs=-1)
def stop(root, services):
config = tutor_config.load(root)
docker_compose(root, config, "rm", "--stop", "--force")
docker_compose(root, config, "rm", "--stop", "--force", *services)
@click.command(
@ -95,15 +97,18 @@ def stop(root):
)
@opts.root
@click.option("-d", "--detach", is_flag=True, help="Start in daemon mode")
def reboot(root, detach):
stop.callback(root)
start.callback(root, detach)
@click.argument("services", metavar="service", nargs=-1)
def reboot(root, detach, services):
stop.callback(root, services)
start.callback(root, detach, services)
@click.command(
short_help="Restart some components from a running platform.",
help="""Specify 'openedx' to restart the lms, cms and workers, or 'all' to
restart all services. Note that this performs a 'docker-compose restart', so new images may not be taken into account. To fully stop the platform, use the 'reboot' command.""",
restart all services. Note that this performs a 'docker-compose restart', so new images
may not be taken into account. It is useful for reloading settings, for instance. To
fully stop the platform, use the 'reboot' command.""",
)
@opts.root
@click.argument("service")
@ -128,7 +133,7 @@ def restart(root, service):
@click.option("--entrypoint", help="Override the entrypoint of the image")
@click.argument("service")
@click.argument("command", default=None, required=False)
@click.argument("args", nargs=-1, required=False)
@click.argument("args", nargs=-1)
def run(root, entrypoint, service, command, args):
run_command = ["run", "--rm"]
if entrypoint:
@ -149,7 +154,7 @@ def run(root, entrypoint, service, command, args):
@opts.root
@click.argument("service")
@click.argument("command")
@click.argument("args", nargs=-1, required=False)
@click.argument("args", nargs=-1)
def execute(root, service, command, args):
exec_command = ["exec", service, command]
if args:
@ -249,7 +254,7 @@ See the official certbot documentation for your platform: https://certbot.eff.or
@opts.root
@click.option("-f", "--follow", is_flag=True, help="Follow log output")
@click.option("--tail", type=int, help="Number of lines to show from each container")
@click.argument("service", nargs=-1, required=False)
@click.argument("service", nargs=-1)
def logs(root, follow, tail, service):
command = ["logs"]
if follow: