[OPS] morning_digest: повтор запроса статуса (хаб бывает занят триажем) и таймаут 30 с
This commit is contained in:
1 parent
9dec0676be
commit
12bafba6b9
1 file changed
+13
-6
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user