import{SCORECARDS_WORKER_KEY as f,scorecardsWorker as m}from"../../../workers/scorecards-worker-pool.js";import{logger as e}from"../../../tools/notifiers/logger.js";import{envConfig as u}from"../../../config/env-config.js";const o=5;async function n(s){const{baseDbDir:c,scorecardsConfig:a,attempt:t}=s;try{const r=await m.exec(f,[{baseDbDir:c,scorecardsConfig:a,pollingIntervalMs:parseInt(u.SCORECARDS_POLLING_INTERVAL_MS||"3000",10)}]);if(r.success)return e.info(`${r.message}`),Promise.resolve();e.error(`Execute Scorecards Worker: failed (attempt ${t}/${o}): ${r.error}`)}catch(r){const i=r instanceof Error?r.message:String(r);e.error(`Execute Scorecards Worker: failed (attempt ${t}/${o}): ${i}`)}return t<o?(e.info(`Execute Scorecards Worker: retrying... (attempt ${t+1}/${o})`),n({baseDbDir:c,scorecardsConfig:a,attempt:t+1})):(e.error(`Execute Scorecards Worker: failed. Scorecards Worker could not be started after all ${o} attempts`),Promise.resolve())}async function p(s,c){return e.info("Start Scorecards Worker: executing..."),n({baseDbDir:s,scorecardsConfig:c,attempt:1})}export{p as runScorecardsWorker};
