MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / runComposeCmdWithLog

Function runComposeCmdWithLog

agent/app/service/runtime_utils.go:201–220  ·  view source on GitHub ↗
(operate string, composePath string, logPath string)

Source from the content-addressed store, hash-verified

199}
200
201func runComposeCmdWithLog(operate string, composePath string, logPath string) error {
202 cmd := getComposeCmd(composePath, operate)
203 logFile, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, constant.FilePerm)
204 if err != nil {
205 global.LOG.Errorf("Failed to open log file: %v", err)
206 return err
207 }
208 defer logFile.Close()
209 multiWriterStdout := io.MultiWriter(os.Stdout, logFile)
210 cmd.Stdout = multiWriterStdout
211 var stderrBuf bytes.Buffer
212 multiWriterStderr := io.MultiWriter(&stderrBuf, logFile, os.Stderr)
213 cmd.Stderr = multiWriterStderr
214
215 err = cmd.Run()
216 if err != nil {
217 return errors.New(buserr.New("ErrRuntimeStart").Error() + ":" + stderrBuf.String())
218 }
219 return nil
220}
221
222func SyncRuntimesStatus(runtimes []model.Runtime) error {
223 cli, err := docker.NewClient()

Callers 5

startRuntimeFunction · 0.85
reCreateRuntimeFunction · 0.85
buildRuntimeFunction · 0.85
restartRuntimeFunction · 0.85
OperateRuntimeMethod · 0.85

Calls 6

getComposeCmdFunction · 0.85
OpenFileMethod · 0.80
CloseMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected