MCPcopy
hub / github.com/NVIDIA/aistore / getProcess

Function getProcess

devtools/tutils/node.go:500–518  ·  view source on GitHub ↗

getProcess finds the ais process by 'lsof' using a port number, it finds the ais process's original command line by 'ps', returns the command line for later to restart(restore) the process.

(port string)

Source from the content-addressed store, hash-verified

498// getProcess finds the ais process by 'lsof' using a port number, it finds the ais process's
499// original command line by 'ps', returns the command line for later to restart(restore) the process.
500func getProcess(port string) (pid int, cmd string, args []string, err error) {
501 pid, err = getPID(port)
502 if err != nil {
503 return 0, "", nil, fmt.Errorf("error getting pid on port: %v", err)
504 }
505
506 output, err := exec.Command("ps", "-p", strconv.Itoa(pid), "-o", "command").CombinedOutput()
507 if err != nil {
508 return 0, "", nil, fmt.Errorf("error executing PS command: %v", err)
509 }
510
511 line := strings.Split(string(output), "\n")[1]
512 fields := strings.Fields(line)
513 if len(fields) == 0 {
514 return 0, "", nil, fmt.Errorf("no returned fields")
515 }
516
517 return pid, fields[0], fields[1:], nil
518}
519
520func WaitForNodeToTerminate(pid int, timeout ...time.Duration) error {
521 var (

Callers 3

KillNodeFunction · 0.85
ShutdownNodeFunction · 0.85
GetRestoreCmdFunction · 0.85

Calls 1

getPIDFunction · 0.85

Tested by

no test coverage detected