Load sessions in parallel
This commit is contained in:
@@ -197,22 +197,31 @@ func (p *pwd) SessionLoadAndPrepare() error {
|
||||
return err
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
for _, s := range sessions {
|
||||
err := p.prepareSession(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, i := range s.Instances {
|
||||
// wire the session back to the instance
|
||||
i.session = s
|
||||
go p.InstanceAttachTerminal(i)
|
||||
}
|
||||
// Connect PWD daemon to the new network
|
||||
if s.PwdIpAddress == "" {
|
||||
return fmt.Errorf("Cannot load stored sessions as they don't have the pwd ip address stored with them")
|
||||
}
|
||||
wg.Add(1)
|
||||
go func(s *Session) {
|
||||
s.rw.Lock()
|
||||
defer s.rw.Unlock()
|
||||
defer wg.Done()
|
||||
|
||||
err := p.prepareSession(s)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
for _, i := range s.Instances {
|
||||
// wire the session back to the instance
|
||||
i.session = s
|
||||
go p.InstanceAttachTerminal(i)
|
||||
}
|
||||
}(s)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
setGauges()
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user