add timeout to daemon startup

This commit is contained in:
Niko Storni 2019-08-13 23:05:09 +02:00
parent df63b91f61
commit 0308da2e4c

View file

@ -324,15 +324,20 @@ func (s *Sync) setChannelTerminationStatus(e *error) {
}
func (s *Sync) waitForDaemonStart() error {
beginTime := time.Now()
for {
select {
case <-s.grp.Ch():
return errors.Err("interrupted during daemon startup")
default:
s, err := s.daemon.Status()
if err == nil && s.StartupStatus.Wallet && s.IsRunning {
status, err := s.daemon.Status()
if err == nil && status.StartupStatus.Wallet && status.IsRunning {
return nil
}
if time.Since(beginTime).Minutes() > 60 {
s.grp.Stop()
return errors.Err("the daemon is taking too long to start. Something is wrong")
}
time.Sleep(5 * time.Second)
}
}