Skip to content

Commit

Permalink
feat: improves healthcheck logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
outofcoffee committed Jan 26, 2024
1 parent 74d3261 commit 03ce532
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/configured-mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,21 @@ export class ConfiguredMock {

waitUntilReady = async (proc: ChildProcess) => {
nodeConsole.debug(`Waiting for mock server to come up on port ${this.port}`);
let ready = false;
while (!ready) {
while (true) {
if (proc.exitCode) {
const advice = this.utils.buildDebugAdvice(this.logToFile, this.logVerbose, this.logFilePath);
throw new Error(`Failed to start mock engine on port ${this.port}. Exit code: ${proc.exitCode}${advice}`);
}
try {
const response = await httpGet(`http://localhost:${this.port}/system/status`);
if (response.status === 200) {
ready = true;
break
}
console.debug('Healthcheck failed', response);
} catch (ignored) {
await this.utils.sleep(200);
console.debug('Healthcheck failed', ignored);
}
await this.utils.sleep(200);
}
nodeConsole.debug('Mock server is up!');
}
Expand Down

0 comments on commit 03ce532

Please sign in to comment.