Skip to content
Closed
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
10 changes: 10 additions & 0 deletions cmd/limactl/start.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"errors"
"fmt"
"io"
Expand All @@ -11,6 +12,7 @@ import (
"path"
"path/filepath"
"strings"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/containerd/containerd/identifiers"
Expand Down Expand Up @@ -55,6 +57,7 @@ $ limactl start --name=default https://raw.githubusercontent.com/lima-vm/lima/ma
startCommand.Flags().Bool("tty", isatty.IsTerminal(os.Stdout.Fd()), "enable TUI interactions such as opening an editor, defaults to true when stdout is a terminal")
startCommand.Flags().String("name", "", "override the instance name")
startCommand.Flags().Bool("list-templates", false, "list available templates and exit")
startCommand.Flags().Int("timeout", 600, "start timeout in seconds")
return startCommand
}

Expand Down Expand Up @@ -458,7 +461,14 @@ func startAction(cmd *cobra.Command, args []string) error {
default:
logrus.Warnf("expected status %q, got %q", store.StatusStopped, inst.Status)
}
// fixme: wait cobra 1.5.0 public with https://github.com/spf13/cobra/pull/1551 then use cmd.SetContext(context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second))
ctx := cmd.Context()
timeout, err := cmd.Flags().GetInt("timeout")
if err != nil {
return err
}
ctx, concel := context.WithTimeout(ctx, time.Duration(timeout)*time.Second)
defer concel()
err = networks.Reconcile(ctx, inst.Name)
if err != nil {
return err
Expand Down
4 changes: 1 addition & 3 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ func waitHostAgentStart(ctx context.Context, haPIDPath, haStderrPath string) err
}

func watchHostAgentEvents(ctx context.Context, inst *store.Instance, haStdoutPath, haStderrPath string, begin time.Time) error {
ctx2, cancel := context.WithTimeout(ctx, 10*time.Minute)
defer cancel()

var (
printedSSHLocalPort bool
Expand Down Expand Up @@ -221,7 +219,7 @@ func watchHostAgentEvents(ctx context.Context, inst *store.Instance, haStdoutPat
return false
}

if xerr := hostagentevents.Watch(ctx2, haStdoutPath, haStderrPath, begin, onEvent); xerr != nil {
if xerr := hostagentevents.Watch(ctx, haStdoutPath, haStderrPath, begin, onEvent); xerr != nil {
return xerr
}

Expand Down