Skip to content

Commit

Permalink
readd closing log before exit
Browse files Browse the repository at this point in the history
  • Loading branch information
ikreymer committed Sep 13, 2023
1 parent 664d0b7 commit 2936e9d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crawler.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ export class Crawler {
await this.crawlState.setStatus(status);
}

await this.closeLog();

process.exit(exitCode);
}
}
Expand Down Expand Up @@ -680,6 +682,7 @@ self.__bx_behaviors.selectMainBehavior();

async serializeAndExit() {
await this.serializeConfig();
await this.closeLog();
process.exit(0);
}

Expand Down Expand Up @@ -855,6 +858,19 @@ self.__bx_behaviors.selectMainBehavior();
}
}

async closeLog() {
// close file-based log
logger.setExternalLogStream(null);
if (!this.logFH) {
return;
}
try {
await new Promise(resolve => this.logFH.close(() => resolve()));
} catch (e) {
// ignore
}
}

async generateWACZ() {
logger.info("Generating WACZ");
await this.crawlState.setStatus("generate-wacz");
Expand Down

0 comments on commit 2936e9d

Please sign in to comment.