@@ -45,7 +45,16 @@ export default class ProfileStatusWatcher {
4545 return { label : `Worker nodes: ${ this . workerReadiness } ` }
4646 }
4747
48+ private async initJobWithDelay ( profile : string , delayMillis = 0 ) {
49+ if ( delayMillis ) {
50+ // delayed start
51+ await new Promise ( ( resolve ) => setTimeout ( resolve , delayMillis ) )
52+ }
53+ return this . initJob ( profile )
54+ }
55+
4856 private initJob ( profile : string ) {
57+ console . error ( "Watcher start" , profile )
4958 const { argv, env } = respawnCommand ( [
5059 "guide" ,
5160 "-q" ,
@@ -72,12 +81,15 @@ export default class ProfileStatusWatcher {
7281 } )
7382
7483 job . on ( "error" , ( ) => {
84+ Debug ( "codeflare" ) ( "Watcher error" , profile )
7585 this . headReadiness = "error"
7686 this . workerReadiness = "error"
87+ this . initJobWithDelay ( profile , 2000 ) // restart after a delay
7788 } )
7889
79- job . on ( "close" , ( exitCode ) => {
80- console . error ( "Watcher exited with code" , exitCode )
90+ job . on ( "close" , async ( exitCode ) => {
91+ Debug ( "codeflare" ) ( "Watcher exited with code" , exitCode )
92+ this . initJobWithDelay ( profile , 2000 ) // restart after a delay
8193 } )
8294
8395 job . stdout . on ( "data" , ( data ) => {
0 commit comments