Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
chore: dbのコネクションの最適化
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Sep 30, 2023
1 parent 46770f3 commit 558310f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/migration/userAfterHookWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ const cluster = require('cluster');

async function main() {
const numWorkers = 16;

await initDb();
await createConnection({
name: "nextDb",
type: "postgres",
host: config.db.nextDb.host,
port: config.db.nextDb.port,
username: config.db.nextDb.user,
password: config.db.nextDb.pass,
database: config.db.nextDb.db,
entities: AyuskeyNextEntities,
});
if (cluster.isPrimary) {
for (let i = 0; i < numWorkers; i++) {
cluster.fork();
Expand All @@ -21,17 +31,7 @@ async function main() {
console.log(`worker ${worker.process.pid} died`);
});
} else {
await initDb();
await createConnection({
name: "nextDb",
type: "postgres",
host: config.db.nextDb.host,
port: config.db.nextDb.port,
username: config.db.nextDb.user,
password: config.db.nextDb.pass,
database: config.db.nextDb.db,
entities: AyuskeyNextEntities,
});

// userQueue.process(userProcessor);

// userQueue.on("completed", (job) => {
Expand Down

0 comments on commit 558310f

Please sign in to comment.