diff --git a/ecosystem.config.js b/ecosystem.config.js index 05c8cae82..024887b6c 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -46,7 +46,7 @@ let arr = [ "group": "backend", }, { - "name": "fullhistory", + "name": "autofullhistory", "script": "svc/autofullhistory.mjs", "group": "backend", }, diff --git a/index.mjs b/index.mjs index 192b889a9..d902baa75 100644 --- a/index.mjs +++ b/index.mjs @@ -15,12 +15,13 @@ if (process.env.ROLE) { import('./' + app.script); } else if (process.env.GROUP) { // or run the group with pm2 - cp.execSync( - 'pm2 start ecosystem.config.js' + cp.execSync('pm2 start ecosystem.config.js'); + setInterval( + () => { + cp.execSync('pm2 flush all'); + }, + 60 * 60 * 1000 ); - setInterval(() => { - cp.execSync('pm2 flush all'); - }, 60 * 60 * 1000); } else { // Block indefinitely (keep process alive for Docker) process.stdin.resume(); diff --git a/svc/counts.mjs b/svc/counts.mjs index a635ee968..503bd2226 100644 --- a/svc/counts.mjs +++ b/svc/counts.mjs @@ -272,7 +272,7 @@ function updateMatchups(match) { }, cb); } */ -async function processCounts(match, cb) { +async function processCounts(match) { console.log('match %s', match.match_id); await updateHeroRankings(match); await upsertMatchSample(match); @@ -282,4 +282,4 @@ async function processCounts(match, cb) { await updateTurbo(match); await updateBenchmarks(match); } -queue.runQueue('countsQueue', 1, processCounts); +await queue.runQueue('countsQueue', 1, processCounts); diff --git a/svc/fullhistory.mjs b/svc/fullhistory.mjs index e960004fa..f5df38903 100644 --- a/svc/fullhistory.mjs +++ b/svc/fullhistory.mjs @@ -129,4 +129,4 @@ async function processFullHistory(job) { await eachLimit(promiseFuncs, parallelism); await updatePlayer(player); } -queue.runQueue('fhQueue', 10, processFullHistory); +await queue.runQueue('fhQueue', 10, processFullHistory); diff --git a/svc/gcdata.mts b/svc/gcdata.mts index d29d0e459..c303b08b6 100644 --- a/svc/gcdata.mts +++ b/svc/gcdata.mts @@ -14,7 +14,7 @@ async function processGcData(job: any) { } console.log('[GCDATA] starting'); -queue.runQueue( +await queue.runQueue( 'gcQueue', Number(config.GCDATA_PARALLELISM) * retrieverArr.length, processGcData diff --git a/svc/mmr.mjs b/svc/mmr.mjs index 4b1bd290b..6c9a3eaed 100644 --- a/svc/mmr.mjs +++ b/svc/mmr.mjs @@ -38,7 +38,7 @@ async function processMmr(job) { await insertPlayerRating(data); } } -queue.runQueue( +await queue.runQueue( 'mmrQueue', config.MMR_PARALLELISM * retrieverArr.length, processMmr diff --git a/svc/parser.mjs b/svc/parser.mjs index 50f5e9758..75939e957 100755 --- a/svc/parser.mjs +++ b/svc/parser.mjs @@ -62,7 +62,7 @@ async function parseProcessor(job) { console.log('[PARSER] completed parse of match %s', match.match_id); return true; } -runReliableQueue( +await runReliableQueue( 'parse', Number(PARSER_PARALLELISM) || numCPUs, parseProcessor diff --git a/svc/profiler.mjs b/svc/profiler.mjs index 6d2af7553..e88e98ce6 100644 --- a/svc/profiler.mjs +++ b/svc/profiler.mjs @@ -41,5 +41,5 @@ while (true) { await Promise.all( results.map((player) => insertPlayerPromise(db, player, false)) ); - await new Promise((resolve) => setTimeout(resolve, 1000)); + await new Promise((resolve) => setTimeout(resolve, 5000)); } diff --git a/svc/scenarios.mjs b/svc/scenarios.mjs index f9079e847..ed19d095c 100644 --- a/svc/scenarios.mjs +++ b/svc/scenarios.mjs @@ -45,4 +45,4 @@ async function processScenarios(matchID) { }); }); } -queue.runQueue('scenariosQueue', 1, processScenarios); +await queue.runQueue('scenariosQueue', 1, processScenarios); diff --git a/test/test.mjs b/test/test.mjs index c8ba1b337..5c56cdb56 100644 --- a/test/test.mjs +++ b/test/test.mjs @@ -23,7 +23,13 @@ import retrieverPlayer from './data/retriever_player.json' assert { type: 'json' import detailsApiPro from './data/details_api_pro.json' assert { type: 'json' }; const { Pool } = pg; -const { INIT_POSTGRES_HOST, INIT_CASSANDRA_HOST, RETRIEVER_HOST, STRIPE_SECRET, POSTGRES_URL } = config; +const { + INIT_POSTGRES_HOST, + INIT_CASSANDRA_HOST, + RETRIEVER_HOST, + STRIPE_SECRET, + POSTGRES_URL, +} = config; const initPostgresHost = `postgres://postgres:postgres@${INIT_POSTGRES_HOST}/postgres`; const initCassandraHost = INIT_CASSANDRA_HOST; @@ -156,9 +162,9 @@ describe('replay parse', function () { assert.ok(match.players); assert.ok(match.players[0]); assert.equal(match.players[0].killed.npc_dota_creep_badguys_melee, 46); - assert.ok(match.players[0].lh_t) + assert.ok(match.players[0].lh_t); assert.ok(match.players[0].lh_t.length); - assert.ok(match.teamfights) + assert.ok(match.teamfights); assert.ok(match.teamfights.length); assert.ok(match.draft_timings); assert.ok(match.radiant_gold_adv);