Skip to content

Commit

Permalink
fix: handle err os exist
Browse files Browse the repository at this point in the history
  • Loading branch information
BaiMeow committed Mar 7, 2024
1 parent 63652b9 commit 8ef1ca1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions daemon/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ func Serve() {
continue
}
go func() {
err := <-utils.Retry(10, func() error {
return quick.Up(cfg, iface, logrus.WithField("iface", iface))
})
if err != nil {
logrus.WithField("iface", iface).WithError(err).Error("failed to up interface, is it already up?")
if err := <-utils.Retry(10, func() error {
err := quick.Up(cfg, iface, logrus.WithField("iface", iface))
if err == nil {
return nil
}
if errors.Is(err, os.ErrExist) {
logrus.WithField("iface", iface).Infoln("interface already up")
return nil
}
return err
}); err != nil {
logrus.WithField("iface", iface).WithError(err).Error("failed to up interface")
return
}
logrus.Infof("interface %s up", iface)
Expand Down

0 comments on commit 8ef1ca1

Please sign in to comment.