cmd/cli: always rebootstrap when check upstream

Otherwise, network changes may not be seen on some platforms, causing
ctrld failed to recover and failing all requests.

While at it, also doing the check DNS in separate goroutine, prevent it
from blocking ctrld from notifying others that it "started". The issue
was seen when ctrld is configured as direct listener, requests are
flooded before ctrld started, causing the healtch process failed.
This commit is contained in:
Cuong Manh Le authored and Cuong Manh Le committed 2023-11-06 20:01:25 +07:00
1 parent 58a00ea24a
commit d88cf52b4e
3 files changed
+18 -12

No files matched your search

+4 -1
View File
@@ -56,7 +56,10 @@ func (p *prog) checkDnsLoop() {
mainLog.Load().Debug().Msg("start checking DNS loop")
upstream := make(map[string]*ctrld.UpstreamConfig)
p.loopMu.Lock()
for _, uc := range p.cfg.Upstream {
for n, uc := range p.cfg.Upstream {
if p.um.isDown("upstream." + n) {
continue
}
uid := uc.UID()
p.loop[uid] = false
upstream[uid] = uc