Skip to content

Commit

Permalink
await runQueue, update service name
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 5, 2023
1 parent 1e4370d commit 67ed9a8
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let arr = [
"group": "backend",
},
{
"name": "fullhistory",
"name": "autofullhistory",
"script": "svc/autofullhistory.mjs",
"group": "backend",
},
Expand Down
11 changes: 6 additions & 5 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions svc/counts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
2 changes: 1 addition & 1 deletion svc/fullhistory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion svc/gcdata.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion svc/mmr.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function processMmr(job) {
await insertPlayerRating(data);
}
}
queue.runQueue(
await queue.runQueue(
'mmrQueue',
config.MMR_PARALLELISM * retrieverArr.length,
processMmr
Expand Down
2 changes: 1 addition & 1 deletion svc/parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion svc/profiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
2 changes: 1 addition & 1 deletion svc/scenarios.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ async function processScenarios(matchID) {
});
});
}
queue.runQueue('scenariosQueue', 1, processScenarios);
await queue.runQueue('scenariosQueue', 1, processScenarios);
12 changes: 9 additions & 3 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 67ed9a8

Please sign in to comment.