all: imp docs

This commit is contained in:
Stanislav Chzhen 2025-08-21 22:37:22 +03:00
parent 971b5bc1b1
commit e400e1757d
4 changed files with 15 additions and 6 deletions

View File

@ -67,6 +67,10 @@ type ExternalCommand struct {
// keyCommand builds a key for a command lookup.
func keyCommand(path string, args []string) (k string) {
if len(args) == 0 {
return path
}
return path + " " + strings.Join(args, " ")
}

View File

@ -114,7 +114,7 @@ func PIDByCommand(
l.DebugContext(ctx, "executing", "cmd", psCmd, "args", psArgs)
stdoutBuf := bytes.Buffer{}
err = executil.Run(
runErr := executil.Run(
ctx,
executil.SystemCommandConstructor{},
&executil.CommandConfig{
@ -123,9 +123,6 @@ func PIDByCommand(
Stdout: &stdoutBuf,
},
)
if err != nil {
return 0, fmt.Errorf("executing the command: %w", err)
}
var instNum int
pid, instNum, err = parsePSOutput(&stdoutBuf, command, except)
@ -143,6 +140,14 @@ func PIDByCommand(
l.WarnContext(ctx, "instances found", "num", instNum, "command", command)
}
if runErr != nil {
if code, ok := executil.ExitCodeFromError(runErr); ok {
return 0, fmt.Errorf("ps finished with code %d", code)
}
return 0, fmt.Errorf("executing the command: %w", runErr)
}
return pid, nil
}

View File

@ -32,7 +32,7 @@ type Interface interface {
// Refresher updates the stored data. It must be safe for concurrent use.
service.Refresher
// Neighbors returnes the last set of data reported by ARP. Both the method
// Neighbors returns the last set of data reported by ARP. Both the method
// and it's result must be safe for concurrent use.
Neighbors() (ns []Neighbor)
}

View File

@ -68,7 +68,7 @@ type Interface interface {
// Refresher updates the stored data. It must be safe for concurrent use.
service.Refresher
// Neighbors returnes the last set of data reported by ARP. Both the method
// Neighbors returns the last set of data reported by ARP. Both the method
// and it's result must be safe for concurrent use.
Neighbors() (ns []arpdb.Neighbor)
}