Skip to content

Commit

Permalink
Terminate Caliper workers on interrupting Caliper manager
Browse files Browse the repository at this point in the history
Signed-off-by: CaptainIRS <[email protected]>
  • Loading branch information
CaptainIRS committed Aug 6, 2022
1 parent 2cdd46d commit aa11c46
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ class RoundOrchestrator {
logger.error(`Could not prepare worker connections: ${err.stack || err}`);
}

process.on('SIGINT', async () => {
logger.info('SIGINT received, stopping workers');
await this._cleanup();
process.exit(0);
});

let benchStartTime = Date.now();

for (const [index, roundConfig] of roundConfigs.entries()) {
Expand Down Expand Up @@ -225,14 +231,24 @@ class RoundOrchestrator {
}
}

// clean up, with "silent" failure handling
try {
this.report.printResultsByRound();
await this.report.finalize();
} catch (err) {
logger.error(`Error while finalizing the report: ${err.stack || err}`);
}

await this._cleanup();

let benchEndTime = Date.now();
logger.info(`Benchmark finished in ${(benchEndTime - benchStartTime)/1000.0} seconds. Total rounds: ${success + failed}. Successful rounds: ${success}. Failed rounds: ${failed}.`);
}

/**
* Stops the benchmark.
*/
async _cleanup() {
// clean up, with "silent" failure handling
try {
await this.monitorOrchestrator.stopAllMonitors();
} catch (err) {
Expand All @@ -244,9 +260,6 @@ class RoundOrchestrator {
} catch (err) {
logger.error(`Error while stopping workers: ${err.stack || err}`);
}

let benchEndTime = Date.now();
logger.info(`Benchmark finished in ${(benchEndTime - benchStartTime)/1000.0} seconds. Total rounds: ${success + failed}. Successful rounds: ${success}. Failed rounds: ${failed}.`);
}
}

Expand Down

0 comments on commit aa11c46

Please sign in to comment.