Skip to content

Dashboard does not shut down when running Java play framework application #6715

Open
@davidfowl

Description

@davidfowl

Discussed in #6672

Originally posted by schmitch November 14, 2024
Hello I have a scala application that I want to run with dotnet/aspire it's a playframework application, however when I try to run it it crashes the aspire dashboard and it does not work:

var builder = DistributedApplication.CreateBuilder(args);

var baseDirectory = Directory.GetParent(builder.AppHostDirectory)?.FullName;
ArgumentException.ThrowIfNullOrEmpty(baseDirectory);

Console.WriteLine($"Using {baseDirectory} as a base path");

var isWin = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
var isMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);

builder
    .AddExecutable("scala-web", "sbt", baseDirectory,
        args: ["run", "-Dplay.server.http.port=9001", "-Dsbt.server.autostart=false"]);

builder.Build().Run();
<Project Sdk="Microsoft.NET.Sdk">
  
  <Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <IsAspireHost>true</IsAspireHost>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Aspire.Hosting.AppHost" Version="9.0.0" />
    <PackageReference Include="Aspire.Hosting.NodeJs" Version="9.0.0" />
  </ItemGroup>
</Project>

What might be problematic is that sbt starts in a reloading mode, i.e. something like dotnet watch. After the run I press Ctrl+C however aspire dashboard keeps running besides that it does not work anymore and I cant rerun it.
the dashboard can be accessed shortly after starting and it also prints that it starts playframework however it does not print everything and than the log just hangs and nothing works.

if I use:

var process = new Process
{
    StartInfo = new ProcessStartInfo
    {
        WorkingDirectory = baseDirectory,
        FileName = "sbt",
        UseShellExecute = true,
        Arguments = "run -Dplay.server.http.port=9001 -Dsbt.server.autostart=false",
    }
};
process.Start();

basically everthing works.

Is there something I'm missing?

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions