I keep getting an error after a few hours that I have too many open files.
I have already edited the ulimit -n
but that only seems to prolong the time before the error occurs and crashes the process.
I believe I have narrowed it down to this function, I just am not sure if I am closing it right.
I currently have a function
go func() {
if _, err := io.Copy(rw, stdout); err != nil {
if !WritePipeBroken.MatchString(err.Error()) &&
!ConnectionResetByPeer.MatchString(err.Error()) {
rollbar.Error(rollbar.ERR, err)
}
log.Printf("pipeThruFfmpegToMp3: %v
", err)
if err := ffmpeg.Process.Kill(); err != nil {
log.Printf("pipeThruFfmpegToMp3: %v
", err)
}
}
rw.Flush()
wg.Done()
}()
I believe that it is hanging, so should I do this instead
go func() {
if _, err := io.Copy(rw, stdout); err != nil {
if !WritePipeBroken.MatchString(err.Error()) &&
!ConnectionResetByPeer.MatchString(err.Error()) {
rollbar.Error(rollbar.ERR, err)
}
log.Printf("pipeThruFfmpegToMp3: %v
", err)
if err := ffmpeg.Process.Kill(); err != nil {
log.Printf("pipeThruFfmpegToMp3: %v
", err)
}
}
if ffmpeg.Process != nil {
ffmpeg.Process.Kill()
}
if stdout != nil {
stdin.Close()
}
rw.Flush()
wg.Done()
}()