mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-10-26 11:27:18 +00:00
all: imp docs
This commit is contained in:
parent
971b5bc1b1
commit
e400e1757d
@ -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, " ")
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user