Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions cmd/limactl/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func newRestartCommand() *cobra.Command {
}

restartCmd.Flags().BoolP("force", "f", false, "Force stop and restart the instance")
restartCmd.Flags().Bool("progress", false, "Show provision script progress by tailing cloud-init logs")
return restartCmd
}

Expand All @@ -40,12 +41,16 @@ func restartAction(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
progress, err := cmd.Flags().GetBool("progress")
if err != nil {
return err
}

if force {
return instance.RestartForcibly(ctx, inst)
return instance.RestartForcibly(ctx, inst, progress)
}

return instance.Restart(ctx, inst)
return instance.Restart(ctx, inst, progress)
}

func restartBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/instance/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import (

const (
launchHostAgentForeground = false
showProgress = false
)

func Restart(ctx context.Context, inst *limatype.Instance) error {
func Restart(ctx context.Context, inst *limatype.Instance, showProgress bool) error {
if err := StopGracefully(ctx, inst, true); err != nil {
return err
}
Expand All @@ -33,7 +32,7 @@ func Restart(ctx context.Context, inst *limatype.Instance) error {
return nil
}

func RestartForcibly(ctx context.Context, inst *limatype.Instance) error {
func RestartForcibly(ctx context.Context, inst *limatype.Instance, showProgress bool) error {
logrus.Info("Restarting the instance forcibly")
StopForcibly(inst)

Expand Down
Loading