Skip to content

Commit

Permalink
introduce --no-deps on restart
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Feb 14, 2023
1 parent 92e0cd4 commit 0612b34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/compose/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
type restartOptions struct {
*ProjectOptions
timeout int
noDeps bool
}

func restartCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
Expand All @@ -44,6 +45,7 @@ func restartCommand(p *ProjectOptions, backend api.Service) *cobra.Command {
}
flags := restartCmd.Flags()
flags.IntVarP(&opts.timeout, "timeout", "t", 10, "Specify a shutdown timeout in seconds")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't restart dependent services.")

return restartCmd
}
Expand All @@ -54,6 +56,13 @@ func runRestart(ctx context.Context, backend api.Service, opts restartOptions, s
return err
}

if opts.noDeps {
err := withSelectedServicesOnly(project, services)
if err != nil {
return err
}
}

timeout := time.Duration(opts.timeout) * time.Second
return backend.Restart(ctx, name, api.RestartOptions{
Timeout: &timeout,
Expand Down
1 change: 1 addition & 0 deletions docs/reference/compose_restart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Restart service containers

| Name | Type | Default | Description |
|:------------------|:------|:--------|:--------------------------------------|
| `--no-deps` | | | Don't restart dependent services. |
| `-t`, `--timeout` | `int` | `10` | Specify a shutdown timeout in seconds |


Expand Down
10 changes: 10 additions & 0 deletions docs/reference/docker_compose_restart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ usage: docker compose restart [OPTIONS] [SERVICE...]
pname: docker compose
plink: docker_compose.yaml
options:
- option: no-deps
value_type: bool
default_value: "false"
description: Don't restart dependent services.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: timeout
shorthand: t
value_type: int
Expand Down

0 comments on commit 0612b34

Please sign in to comment.