@@ -18,7 +18,7 @@ export class TraceServer {
1818 private server : ChildProcess | undefined ;
1919
2020 private start ( context : vscode . ExtensionContext | undefined ) {
21- const from = vscode . workspace . getConfiguration ( section ) ;
21+ const from = this . getSettings ( ) ;
2222 const server = spawn ( this . getPath ( from ) , this . getArgs ( from ) ) ;
2323
2424 if ( ! server . pid ) {
@@ -27,8 +27,7 @@ export class TraceServer {
2727 }
2828 this . server = server ;
2929 context ?. workspaceState . update ( key , this . server . pid ) ;
30- const serverUrl = this . getUrl ( from ) + '/' + this . getApiPath ( from ) ;
31- this . waitFor ( serverUrl , context ) ;
30+ this . waitFor ( context ) ;
3231 }
3332
3433 stopOrReset ( context : vscode . ExtensionContext | undefined ) {
@@ -113,7 +112,16 @@ export class TraceServer {
113112 }
114113 getApiPath_test = this . getApiPath ;
115114
116- private async waitFor ( serverUrl : string , context : vscode . ExtensionContext | undefined ) {
115+ private getSettings ( ) {
116+ return vscode . workspace . getConfiguration ( section ) ;
117+ }
118+
119+ private getServerUrl ( ) {
120+ const from = this . getSettings ( ) ;
121+ return this . getUrl ( from ) + '/' + this . getApiPath ( from ) ;
122+ }
123+
124+ private async waitFor ( context : vscode . ExtensionContext | undefined ) {
117125 vscode . window . withProgress (
118126 {
119127 location : vscode . ProgressLocation . Notification ,
@@ -127,7 +135,7 @@ export class TraceServer {
127135
128136 // eslint-disable-next-line no-constant-condition
129137 while ( true ) {
130- if ( await this . isUp ( serverUrl ) ) {
138+ if ( await this . isUp ( ) ) {
131139 this . showStatus ( true ) ;
132140 this . server ?. once ( exit , ( ) => {
133141 this . stopOrReset ( context ) ;
@@ -145,8 +153,8 @@ export class TraceServer {
145153 ) ;
146154 }
147155
148- private async isUp ( serverUrl : string ) {
149- const client = new TspClient ( serverUrl ) ;
156+ private async isUp ( ) {
157+ const client = new TspClient ( this . getServerUrl ( ) ) ;
150158 const health = await client . checkHealth ( ) ;
151159 const status = health . getModel ( ) ?. status ;
152160 return health . isOk ( ) && status === 'UP' ;
0 commit comments