@@ -432,12 +432,37 @@ export async function bootstrapLando( options: LandoBootstrapOptions = {} ): Pro
432432 }
433433}
434434
435- export async function landoStart ( lando : Lando , instancePath : string ) : Promise < void > {
435+ function installDnsAutofixer ( app : App ) : void {
436+ app . events . on ( 'post-start' , 9 , async ( ) => {
437+ const urlsToScan : string [ ] = [ ] ;
438+ app . info
439+ . filter ( service => service . urls . length )
440+ . forEach ( service => {
441+ service . urls . forEach ( url => {
442+ if ( ! / ^ h t t p s ? : \/ \/ ( l o c a l h o s t | 1 2 7 \. 0 \. 0 \. 1 ) : / . exec ( url ) && ! url . includes ( '*' ) ) {
443+ urlsToScan . push ( url ) ;
444+ }
445+ } ) ;
446+ } ) ;
447+
448+ await tryResolveDomains ( urlsToScan , true ) ;
449+ } ) ;
450+ }
451+
452+ export async function landoStart (
453+ lando : Lando ,
454+ instancePath : string ,
455+ autoFixDomainResolution = false
456+ ) : Promise < void > {
436457 const started = new Date ( ) ;
437458 try {
438459 debug ( 'Will start lando app on path:' , instancePath ) ;
439460
440461 const app = await getLandoApplication ( lando , instancePath ) ;
462+ if ( autoFixDomainResolution ) {
463+ installDnsAutofixer ( app ) ;
464+ }
465+
441466 await app . start ( ) ;
442467 } finally {
443468 const duration = new Date ( ) . getTime ( ) - started . getTime ( ) ;
@@ -471,12 +496,19 @@ export async function landoLogs( lando: Lando, instancePath: string, options: La
471496 }
472497}
473498
474- export async function landoRebuild ( lando : Lando , instancePath : string ) : Promise < void > {
499+ export async function landoRebuild (
500+ lando : Lando ,
501+ instancePath : string ,
502+ autoFixDomainResolution = false
503+ ) : Promise < void > {
475504 const started = new Date ( ) ;
476505 try {
477506 debug ( 'Will rebuild lando app on path:' , instancePath ) ;
478507
479508 const app = await getLandoApplication ( lando , instancePath ) ;
509+ if ( autoFixDomainResolution ) {
510+ installDnsAutofixer ( app ) ;
511+ }
480512
481513 await ensureNoOrphantProxyContainer ( lando ) ;
482514 await app . rebuild ( ) ;
@@ -550,7 +582,6 @@ export async function landoDestroy( lando: Lando, instancePath: string ): Promis
550582interface LandoInfoOptions {
551583 suppressWarnings ?: boolean ;
552584 autologinKey ?: string ;
553- autofixDomains ?: boolean ;
554585}
555586
556587interface LandoInfoResult extends AppInfo {
@@ -577,7 +608,7 @@ export async function landoInfo(
577608 const reachableServices = app . info . filter ( service => service . urls . length ) ;
578609 reachableServices . forEach ( service => ( info [ `${ service . service } urls` ] = service . urls ) ) ;
579610
580- const health = await checkEnvHealth ( lando , app , Boolean ( options . autofixDomains ) ) ;
611+ const health = await checkEnvHealth ( lando , app ) ;
581612 const frontEndUrl = app . info . find ( service => 'nginx' === service . service ) ?. urls [ 0 ] ?? '' ;
582613
583614 const extraService = await getExtraServicesConnections ( lando , app ) ;
@@ -701,7 +732,7 @@ async function getExtraServicesConnections(
701732 return extraServices ;
702733}
703734
704- async function tryResolveDomains ( urls : string [ ] , autofix : boolean ) : Promise < void > {
735+ export async function tryResolveDomains ( urls : string [ ] , autofix : boolean ) : Promise < void > {
705736 const domains = [
706737 ...new Set (
707738 urls
@@ -822,8 +853,7 @@ async function getRunningServicesForProject(
822853
823854export async function checkEnvHealth (
824855 lando : Lando ,
825- app : App ,
826- autofixDomainResolution : boolean = false
856+ app : App
827857) : Promise < Record < string , boolean > > {
828858 const urls : Record < string , string > = { } ;
829859
@@ -841,7 +871,7 @@ export async function checkEnvHealth(
841871 } ) ;
842872
843873 const urlsToScan = Object . keys ( urls ) . filter ( url => ! url . includes ( '*' ) ) ;
844- await tryResolveDomains ( urlsToScan , autofixDomainResolution ) ;
874+ await tryResolveDomains ( urlsToScan , false ) ;
845875 app . urls . forEach ( entry => {
846876 // We use different status codes to see if the service is up.
847877 // We may consider the service is up when Lando considers it is down.
0 commit comments