From 5739df406a8facabdbff16468b98658110f21217 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Thu, 21 Sep 2023 07:48:51 +0100 Subject: [PATCH] Context close docs - Backport #863 - Relates #866 --- ...sing-shell-customization-contextclose.adoc | 23 +++++++++++++++++++ .../asciidoc/using-shell-customization.adoc | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 spring-shell-docs/src/main/asciidoc/using-shell-customization-contextclose.adoc diff --git a/spring-shell-docs/src/main/asciidoc/using-shell-customization-contextclose.adoc b/spring-shell-docs/src/main/asciidoc/using-shell-customization-contextclose.adoc new file mode 100644 index 00000000..a302b066 --- /dev/null +++ b/spring-shell-docs/src/main/asciidoc/using-shell-customization-contextclose.adoc @@ -0,0 +1,23 @@ +[[using-shell-customization-contextclose]] +=== Context Close + +Command execution logic happens via Spring Boot's `ApplicationRunner` beans. +Normally Spring `ApplicationContext` closes automatically after these runner +beans has been processed unless there is something what keeps it alive like +use of `@EnableScheduling` or generally speaking there are threads which +don't die automatically. + +It is possible to add configuration property `spring.shell.context.close` +which registers `ApplicationListener` for `ApplicationReadyEvent` and requests +context close after shell has completed its execution logic. + +[source, yaml] +---- +spring: + shell: + context: + close: true +---- + +NOTE: This setting is not enabled by default. + diff --git a/spring-shell-docs/src/main/asciidoc/using-shell-customization.adoc b/spring-shell-docs/src/main/asciidoc/using-shell-customization.adoc index e1c80c1c..c8b1d854 100644 --- a/spring-shell-docs/src/main/asciidoc/using-shell-customization.adoc +++ b/spring-shell-docs/src/main/asciidoc/using-shell-customization.adoc @@ -10,3 +10,5 @@ include::using-shell-customization-logging.adoc[] include::using-shell-customization-commandnotfound.adoc[] include::using-shell-customization-singlecommand.adoc[] + +include::using-shell-customization-contextclose.adoc[]