diff --git a/ops/scripts/morning_digest.py b/ops/scripts/morning_digest.py index 248f0ed..2bb93ee 100755 --- a/ops/scripts/morning_digest.py +++ b/ops/scripts/morning_digest.py @@ -42,12 +42,19 @@ def sh(cmd, timeout=60): def services(): - try: - import urllib.request as u - with u.urlopen(HUB + "/status.json", timeout=15) as r: - d = json.loads(r.read()) - except Exception: - return "• Службы: хаб не отвечает", [] + import urllib.request as u + d = None + for attempt in range(2): + try: + with u.urlopen(HUB + "/status.json", timeout=30) as r: + d = json.loads(r.read()) + break + except Exception: + if attempt == 0: + import time as _t + _t.sleep(3) + if d is None: + return "• Службы: хаб не отвечает (2 попытки)", [] svc = d.get("services") or [] down = [s.get("name") for s in svc if not s.get("up")] if down: