Add reliable execution reporting and coordinated dashboard views
This commit is contained in:
+15
-2
@@ -131,11 +131,24 @@ def main():
|
||||
args=parser.parse_args()
|
||||
cfg=json.loads(Path(args.config).read_text(encoding='utf-8-sig'))
|
||||
client=Client(cfg['control'])
|
||||
failures=0
|
||||
limit=cfg.get('mirror_retry_limit',3)
|
||||
if not isinstance(limit,int) or isinstance(limit,bool) or not 1<=limit<=5:
|
||||
raise ValueError('Mirror retries must be bounded between 1 and 5')
|
||||
with AppServer(cfg.get('codex')) as server:
|
||||
while True:
|
||||
count=sync(server,client,cfg)
|
||||
from worker import atomic_json
|
||||
atomic_json(Path(cfg['state_file']).parent/'mirror-health.json',{'status':'ok','updated':time.time()})
|
||||
try:
|
||||
count=sync(server,client,cfg)
|
||||
failures=0
|
||||
atomic_json(Path(cfg['state_file']).parent/'mirror-health.json',{'status':'ok','updated':time.time()})
|
||||
except Exception:
|
||||
failures+=1
|
||||
atomic_json(Path(cfg['state_file']).parent/'mirror-health.json',{'status':'retrying','updated':time.time(),'attempt':failures})
|
||||
if args.once or failures>=limit:raise
|
||||
print('Mirror connection interrupted; bounded retry '+str(failures),flush=True)
|
||||
time.sleep(min(2**failures,8))
|
||||
continue
|
||||
print(json.dumps({'thread_id':cfg['thread_id'],'visible_items':count}),flush=True)
|
||||
if args.once:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user