这是我的代码(writeFromProcessToFileWithMax是一个内部函数,并且工作正常):
// Go routines for non-blocking reading of stdout and stderr and writing to files
g := new(errgroup.Group)
// Read stdout in goroutine.
g.Go(func() error {
err = writeFromProcessToFileWithMax(stdoutScanner, stdoutFileWriter, maxStdoutFileLengthInGB)
if err != nil {
log.Error().Err(err).Msgf("Error writing to stdout file: %s", stdoutFilename)
return err
}
return nil
})
// Read stderr in goroutine.
g.Go(func() error {
err = writeFromProcessToFileWithMax(stderrScanner, stderrFileWriter, maxStderrFileLengthInGB)
if err != nil {
log.Error().Err(err).Msgf("Error writing to stderr file: %s", stderrFilename)
return err
}
return nil
})
// Wait the command in a goroutine.
g.Go(func() error {
return cmd.Wait()
})
// Starting the command
if err = cmd.Start(); err != nil {
log.Error().Err(err).Msg("Error starting command")
return err
}
// Waiting until errorGroups groups are done
if err = g.Wait(); err != nil {
log.Error().Err(err).Msg("Error during running of the command")
}
当我运行它时,我得到以下 Error = Error during running of the command error="exec: not started"。但一切正常。
它会回来咬我还是我应该压制?
一只萌萌小番薯
相关分类