Stop all processes in parallel for fast shutdown

This commit is contained in:
Ingo Oppermann 2023-12-12 20:59:01 +01:00
parent 74489775ca
commit a330ea6e7f
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -251,11 +251,24 @@ func (r *restream) Stop() {
// Stop the currently running processes without altering their order such that on a subsequent
// Start() they will get restarted.
for id, t := range r.tasks {
if t.ffmpeg != nil {
t.ffmpeg.Stop(true)
wg := sync.WaitGroup{}
for _, t := range r.tasks {
if t.ffmpeg == nil {
continue
}
wg.Add(1)
go func(p process.Process) {
defer wg.Done()
p.Stop(true)
}(t.ffmpeg)
}
wg.Wait()
for id := range r.tasks {
r.unsetCleanup(id)
}