Commit 3f76fec1 authored by nanahira's avatar nanahira

add more logs

parent 0ce51300
Pipeline #25385 passed with stages
in 2 minutes and 34 seconds
...@@ -227,7 +227,7 @@ export class PackagerService extends ConsoleLogger { ...@@ -227,7 +227,7 @@ export class PackagerService extends ConsoleLogger {
private archiveQueue = new PQueue({ concurrency: parseInt(process.env.PACKAGE_COCURRENCY) || os.cpus().length }); private archiveQueue = new PQueue({ concurrency: parseInt(process.env.PACKAGE_COCURRENCY) || os.cpus().length });
private async archiveProcess(root: string, archiveTask: ArchiveTask): Promise<Archive> { private async archiveProcess(root: string, archiveTask: ArchiveTask, retry = 0): Promise<Archive> {
const archive = archiveTask.archive; const archive = archiveTask.archive;
const archiveName = archiveTask.archiveFullPath; const archiveName = archiveTask.archiveFullPath;
const existing = await this.s3.fileExists(archiveName); const existing = await this.s3.fileExists(archiveName);
...@@ -263,7 +263,10 @@ export class PackagerService extends ConsoleLogger { ...@@ -263,7 +263,10 @@ export class PackagerService extends ConsoleLogger {
}); });
}); });
const hashObject = createHash('sha256'); const hashObject = createHash('sha256');
let length = 0;
child.stdout.on('data', (chunk) => { child.stdout.on('data', (chunk) => {
length += chunk.length;
this.log(`Received ${length} bytes of archive ${archiveName}.`);
hashObject.update(chunk); hashObject.update(chunk);
}); });
...@@ -272,6 +275,7 @@ export class PackagerService extends ConsoleLogger { ...@@ -272,6 +275,7 @@ export class PackagerService extends ConsoleLogger {
try { try {
if (files.length > 1000) { if (files.length > 1000) {
this.warn(`Too many files in archive ${archiveName}, using tmp file.`);
// minio would skew the stream if it's too slow // minio would skew the stream if it's too slow
// use a tmp file to put the stream // use a tmp file to put the stream
...@@ -295,8 +299,15 @@ export class PackagerService extends ConsoleLogger { ...@@ -295,8 +299,15 @@ export class PackagerService extends ConsoleLogger {
archive.hash = hashObject.digest('hex'); archive.hash = hashObject.digest('hex');
await this.redis.set(`hash:${archive.path}`, archive.hash, 'EX', 60 * 60 * 24); await this.redis.set(`hash:${archive.path}`, archive.hash, 'EX', 60 * 60 * 24);
archive.size = object.Size; archive.size = object.Size;
this.log(`Finished archiving ${archiveName} with ${length} bytes.`);
return archive; return archive;
} catch (e) {
this.error(`Failed to archive ${archiveName}: ${e.toString()}`);
if (retry < 3) {
this.warn(`Retrying archive ${archiveName}.`);
return this.archiveProcess(root, archiveTask, retry + 1);
}
throw e;
} finally { } finally {
if (tmpFilename) { if (tmpFilename) {
await fs.promises.rm(tmpFilename); await fs.promises.rm(tmpFilename);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment