Skip to content

Commit

Permalink
Korjattu Lampi-siirron lokitusta ja lisätty resursseja
Browse files Browse the repository at this point in the history
  • Loading branch information
augustk committed Jan 9, 2025
1 parent 6c7655b commit 181dc9d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cdk/lib/ecs-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ export class EcsStack extends cdk.Stack {
scheduledFargateTaskImageOptions: {
image: lampiSiirtajaImage,
logDriver: lampiSiirtajaLogDriver,
cpu: 1024,
memoryLimitMiB: 2048,
cpu: 2048,
memoryLimitMiB: 6144,
environment: {
POSTGRES_HOST: `raportointi.db.${config.publicHostedZone}`,
DB_USERNAME: 'app',
Expand Down
2 changes: 1 addition & 1 deletion lampi-siirtaja-container/lampi-siirtaja/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"xtend": "^4.0.2"
},
"scripts": {
"start": "tsc && node dist/run.js",
"start": "tsc && node --max-old-space-size=4096 dist/run.js",
"lint": "eslint . --ext .ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
9 changes: 5 additions & 4 deletions lampi-siirtaja-container/lampi-siirtaja/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ const copyTableToS3 = (schemaName: string, tableName: string) => {
pgClient.connectSync(dbUri);
const queryResult = pgClient.querySync(sql);
console.log(`QueryResult: ${JSON.stringify(queryResult, null, 4)}`);
console.log(`Taulun ${tableName} kopioinnin tulos | Rivien määrä: ${queryResult.rows_uploaded} | Tiedostojen määrä: ${queryResult.files_uploaded} | Tiedostojen koko: ${queryResult.bytes_uploaded}`);
if(queryResult.files_uploaded !== '1') console.error(`Scheman ${schemaName} taulusta ${tableName} muodostui S3-ämpäriin useampi kuin yksi tiedosto (${queryResult.files_uploaded})`);
const result = queryResult[0] || {};
console.log(`Taulun ${tableName} kopioinnin tulos | Rivien määrä: ${result.rows_uploaded} | Tiedostojen määrä: ${result.files_uploaded} | Tiedostojen koko: ${result.bytes_uploaded}`);
if(result.files_uploaded !== '1') console.error(`Scheman ${schemaName} taulusta ${tableName} muodostui S3-ämpäriin useampi kuin yksi tiedosto (${result.files_uploaded})`);
}

const copyFileToLampi = async (sourceKey: string): Promise<ManifestItem> => {
Expand Down Expand Up @@ -96,15 +97,15 @@ const copyFileToLampi = async (sourceKey: string): Promise<ManifestItem> => {
ContentType: 'text/csv'
}

const parallelUploads3 = new Upload({
const parallelS3Upload = new Upload({
client: lampiS3Client,
queueSize: 4, // rinnakkaisuus
partSize: 524288000, // 500MB
leavePartsOnError: false,
params: target,
});

const completeMultipartUploadCommandOutput: CompleteMultipartUploadCommandOutput = await parallelUploads3.done();
const completeMultipartUploadCommandOutput: CompleteMultipartUploadCommandOutput = await parallelS3Upload.done();

console.log(`Siirretty ${ovaraLampiSiirtajaBucket}/${sourceKey} => ${lampiS3Bucket}/${destinationKey}`);

Expand Down

0 comments on commit 181dc9d

Please sign in to comment.