Fix installer to not explode on long lines; closes pterodactyl/panel#2773

This commit is contained in:
Dane Everitt
2020-12-25 17:05:01 -08:00
parent 59c30c2842
commit 22c53c365a
2 changed files with 54 additions and 12 deletions

View File

@@ -506,21 +506,15 @@ func (ip *InstallationProcess) StreamOutput(ctx context.Context, id string) erro
if err != nil {
return err
}
defer reader.Close()
s := bufio.NewScanner(reader)
for s.Scan() {
ip.Server.Events().Publish(InstallOutputEvent, s.Text())
evts := ip.Server.Events()
err = system.ScanReader(reader, func(line string) {
evts.Publish(InstallOutputEvent, line)
})
if err != nil {
ip.Server.Log().WithFields(log.Fields{"container_id": id, "error": err}).Warn("error processing install output lines")
}
if err := s.Err(); err != nil {
ip.Server.Log().WithFields(log.Fields{
"container_id": id,
"error": err,
}).Warn("error processing scanner line in installation output for server")
}
return nil
}