Skip to content

Commit 20eac28

Browse files
committed
TraceServer: Make the 'UP' server check reusable
Prepare the ground for a follow-up fix about adding another such check. Contributes to fixing #8. Signed-off-by: Marco Miller <marco.miller@ericsson.com>
1 parent 91f8f9b commit 20eac28

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/trace-server.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,12 @@ export class TraceServer {
122122
},
123123
async progress => {
124124
progress.report({ message: 'Starting up...' });
125-
const client = new TspClient(serverUrl);
126125
let timeout = false;
127126
const timeoutId = setTimeout(() => (timeout = true), millis);
128127

129128
// eslint-disable-next-line no-constant-condition
130129
while (true) {
131-
const health = await client.checkHealth();
132-
const status = health.getModel()?.status;
133-
134-
if (health.isOk() && status === 'UP') {
130+
if (await this.isUp(serverUrl)) {
135131
this.showStatus(true);
136132
this.server?.once(exit, () => {
137133
this.stopOrReset(context);
@@ -149,6 +145,13 @@ export class TraceServer {
149145
);
150146
}
151147

148+
private async isUp(serverUrl: string) {
149+
const client = new TspClient(serverUrl);
150+
const health = await client.checkHealth();
151+
const status = health.getModel()?.status;
152+
return health.isOk() && status === 'UP';
153+
}
154+
152155
private showError(message: string) {
153156
console.error(message);
154157
vscode.window.showErrorMessage(message);

0 commit comments

Comments
 (0)