Skip to content

Commit d2e92b2

Browse files
authored
Print the url with the token when we print the dashboard url (#3475)
- Today we're waiting until the app started and that can take a long time when provisioning resources. Instead, just print the token url when we print the dashboard url.
1 parent 6eb0480 commit d2e92b2

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/Aspire.Hosting/Dcp/ApplicationExecutor.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,8 @@ private async Task StartDashboardAsDcpExecutableAsync(CancellationToken cancella
830830
await kubernetesService.CreateAsync(dashboardExecutable, cancellationToken).ConfigureAwait(false);
831831

832832
var dashboardUrls = env.Single(e => e.Key == DashboardConfigNames.DashboardFrontendUrlName.EnvVarName).Value;
833-
PrintDashboardUrls(dashboardUrls);
833+
var browserToken = env.SingleOrDefault(e => e.Key == DashboardConfigNames.DashboardFrontendBrowserTokenName.EnvVarName).Value;
834+
PrintDashboardUrls(dashboardUrls, browserToken);
834835
}
835836

836837
private async Task<List<KeyValuePair<string, string>>> GetDashboardEnvironmentVariablesAsync(IConfiguration configuration, string? defaultDashboardUrl, CancellationToken cancellationToken)
@@ -882,12 +883,17 @@ private async Task<List<KeyValuePair<string, string>>> GetDashboardEnvironmentVa
882883
return env;
883884
}
884885

885-
private void PrintDashboardUrls(string delimitedUrlList)
886+
private void PrintDashboardUrls(string delimitedUrlList, string? browserToken)
886887
{
887888
if (StringUtils.TryGetUriFromDelimitedString(delimitedUrlList, ";", out var firstDashboardUrl))
888889
{
889890
distributedApplicationLogger.LogInformation("Now listening on: {DashboardUrl}", firstDashboardUrl.ToString().TrimEnd('/'));
890891
}
892+
893+
if (!string.IsNullOrEmpty(browserToken))
894+
{
895+
LoggingHelpers.WriteDashboardUrl(distributedApplicationLogger, delimitedUrlList, browserToken);
896+
}
891897
}
892898

893899
private async Task CreateServicesAsync(CancellationToken cancellationToken = default)
@@ -1330,7 +1336,9 @@ private async Task CreateExecutableAsync(AppResource er, ILogger resourceLogger,
13301336
throw new DistributedApplicationException("Cannot check dashboard availability since ASPNETCORE_URLS environment variable not set.");
13311337
}
13321338

1333-
PrintDashboardUrls(dashboardUrls);
1339+
var browserToken = configuration["AppHost:BrowserToken"];
1340+
1341+
PrintDashboardUrls(dashboardUrls, browserToken);
13341342
}
13351343
}
13361344

src/Aspire.Hosting/DistributedApplicationLifecycle.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace Aspire.Hosting;
1111
internal sealed class DistributedApplicationLifecycle(
1212
ILogger<DistributedApplication> logger,
1313
IConfiguration configuration,
14-
DistributedApplicationExecutionContext executionContext,
15-
DistributedApplicationOptions distributedApplicationOptions) : IHostedLifecycleService
14+
DistributedApplicationExecutionContext executionContext) : IHostedLifecycleService
1615
{
1716
public Task StartAsync(CancellationToken cancellationToken)
1817
{
@@ -23,11 +22,6 @@ public Task StartedAsync(CancellationToken cancellationToken)
2322
{
2423
if (executionContext.IsRunMode)
2524
{
26-
if (distributedApplicationOptions.DashboardEnabled && configuration["AppHost:BrowserToken"] is { Length: > 0 } browserToken)
27-
{
28-
LoggingHelpers.WriteDashboardUrl(logger, configuration["ASPNETCORE_URLS"], browserToken);
29-
}
30-
3125
logger.LogInformation("Distributed application started. Press Ctrl+C to shut down.");
3226
}
3327

0 commit comments

Comments
 (0)