MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / RunCommandNB

Function RunCommandNB

utils/exec.go:72–106  ·  view source on GitHub ↗

RunCommandNB starts a non-blocking command.

(bin string, args []string, processName string, workingDir string, logDir string, toStd bool)

Source from the content-addressed store, hash-verified

70
71// RunCommandNB starts a non-blocking command.
72func RunCommandNB(bin string, args []string, processName string, workingDir string, logDir string, toStd bool) (cmd *CMD, err error) {
73 cmd = new(CMD)
74 err = os.Chdir(workingDir)
75 if err != nil {
76 log.WithField("wd", workingDir).Error("change working dir failed")
77 return
78 }
79
80 cmd.LogPath = FJ(logDir, processName+".log")
81 cmd.LogFD, err = os.Create(cmd.LogPath)
82 if err != nil {
83 log.WithField("path", cmd.LogPath).WithError(err).Error("create log file failed")
84 return
85 }
86
87 cmd.Cmd = exec.Command(bin, args...)
88
89 if toStd {
90 cmd.Cmd.Stdout = io.MultiWriter(os.Stdout, cmd.LogFD)
91 cmd.Cmd.Stderr = io.MultiWriter(os.Stderr, cmd.LogFD)
92 } else {
93 cmd.Cmd.Stdout = cmd.LogFD
94 cmd.Cmd.Stderr = cmd.LogFD
95 }
96
97 err = cmd.Cmd.Start()
98 if err != nil {
99 log.WithError(err).Error("cmd.Start() failed")
100 _ = cmd.LogFD.Close()
101 cmd = nil
102 return
103 }
104
105 return
106}

Callers 10

startNodesFunction · 0.92
TestFullProcessFunction · 0.92
startNodesFunction · 0.92
TestFullProcessFunction · 0.92
start3BPsFunction · 0.92
startNodesFunction · 0.92
startNodesFunction · 0.92
startNodesProfileFunction · 0.92
RunCommandFunction · 0.85

Calls 7

WithFieldFunction · 0.92
WithErrorFunction · 0.92
ErrorMethod · 0.80
WithErrorMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65
StartMethod · 0.45

Tested by 9

startNodesFunction · 0.74
TestFullProcessFunction · 0.74
startNodesFunction · 0.74
TestFullProcessFunction · 0.74
start3BPsFunction · 0.74
startNodesFunction · 0.74
startNodesFunction · 0.74
startNodesProfileFunction · 0.74