File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 2
2
import logging
3
3
import signal
4
4
import time
5
+ import sys
5
6
from threading import Event
6
7
7
8
from prometheus_client import start_http_server
@@ -32,13 +33,20 @@ async def main():
32
33
process = Process (config )
33
34
34
35
retry_time = 5
36
+ retry_count = 0
35
37
while not STOP_EVENT .is_set ():
36
38
try :
37
39
now = time .time ()
38
40
await process .load (int (now ))
39
41
break
40
42
except PrometheusException as exc :
41
43
logger .error (exc )
44
+
45
+ retry_count += 1
46
+ if retry_count > 5 :
47
+ logger .critical (f"Unable to initialize, aborting!" )
48
+ return 1
49
+
42
50
logger .error (f"Retrying in { retry_time } seconds..." )
43
51
await asyncio .sleep (retry_time )
44
52
retry_time += 5
@@ -61,7 +69,10 @@ async def main():
61
69
wait_time = REFRESH_INTERVAL - overshot
62
70
time_target += REFRESH_INTERVAL
63
71
72
+ return 0
73
+
64
74
65
75
if __name__ == "__main__" :
66
76
loop = asyncio .get_event_loop ()
67
77
res = loop .run_until_complete (main ())
78
+ sys .exit (res )
You can’t perform that action at this time.
0 commit comments