Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EnsurePortsFreeCmd = &cobra.Command{ Use: "ensure-ports-free PORT [PORT...]", Short: "Ensure the given TCP ports are free, terminating a matching stale process if needed", Hidden: true, Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ports := make([]int, 0, len(args)) for _, a := range args { p, err := strconv.Atoi(a) if err != nil { return fmt.Errorf("invalid port %q: %w", a, err) } ports = append(ports, p) } err := portguard.EnsureReleased(context.Background(), portguard.Options{ Ports: ports, ProcessNameContains: ensurePortsFreePattern, Timeout: ensurePortsFreeTimeout, ExcludePID: ensurePortsFreeExcludePID, }) if err != nil { return err } fmt.Printf("ports free: %s\n", strings.Trim(fmt.Sprint(ports), "[]")) return nil }, }
EnsurePortsFreeCmd is a hidden operational command used by scripts/install-service.sh and scripts/dev-restart-guard.sh to guarantee a set of ports are unbound before the next stapler-squad instance starts — actively terminating a stale holder rather than waiting a fixed duration and proceeding regardless. See pkg/portguard's package doc for the incident history this replaces.
View Source
var GetSessionCmd = &cobra.Command{ Use: "get-session [name]", Short: "Get information about a session", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { client := sessionv1connect.NewSessionServiceClient( http.DefaultClient, "http://localhost:8080/api", ) req := &connect.Request[sessionv1.GetSessionRequest]{ Msg: &sessionv1.GetSessionRequest{ Id: args[0], }, } resp, err := client.GetSession(context.Background(), req) if err != nil { return fmt.Errorf("could not get session: %w", err) } jsonData, err := json.MarshalIndent(resp.Msg.Session, "", " ") if err != nil { return fmt.Errorf("could not marshal session data to json: %w", err) } fmt.Println(string(jsonData)) return nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.