Ensure command shell exits when cmdfile is finished.

Closes #31
This commit is contained in:
Mark Paluch
2023-02-17 13:08:36 +01:00
parent d0a0f70545
commit d3b72a0085

View File

@@ -19,6 +19,8 @@ import java.util.logging.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.shell.core.ExitShellRequest;
import org.springframework.shell.support.logging.HandlerUtils;
/**
@@ -31,14 +33,20 @@ public class Application {
SpringApplication application = new SpringApplication(Application.class);
application.setAdditionalProfiles("local");
ExitShellRequest exitShellRequest = null;
try (ConfigurableApplicationContext context = application.run(args)) {
BootShim bs = new BootShim(args, context);
exitShellRequest = bs.run();
try {
BootShim bs = new BootShim(args, application.run(args));
bs.run();
} catch (RuntimeException e) {
throw e;
} finally {
HandlerUtils.flushAllHandlers(Logger.getLogger(""));
}
if (exitShellRequest != null) {
System.exit(exitShellRequest.getExitCode());
}
}
}