NIFI-9688 Improve Logback shutdown handling (#5805)

* NIFI-9688 Improved Logback shutdown handling
- Added environment variable to disable Logback shutdown on web application termination
- Added shutdown hook to Logback configuration
- Added Logback shutdown hook configuration to system tests
This commit is contained in:
exceptionfactory 2022-02-28 14:29:44 -05:00 committed by GitHub
parent ddecfa201b
commit 52f21390db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 22 additions and 2 deletions

View File

@ -50,6 +50,9 @@ export NIFI_PID_DIR
NIFI_LOG_DIR="$(setOrDefault "$NIFI_LOG_DIR" "$NIFI_HOME/logs")"
export NIFI_LOG_DIR
# Disable automatic Logback Initializer to avoid shutdown on web application termination
export logbackDisableServletContainerInitializer="true"
# Set to false to force the use of Keytab controller service in processors
# that use Kerberos. If true, these processors will allow configuration of keytab
# and principal directly within the processor. If false, these processors will be

View File

@ -15,6 +15,8 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>

View File

@ -95,9 +95,9 @@ public class ApplicationStartupContextListener implements ServletContextListener
@Override
public void contextDestroyed(ServletContextEvent sce) {
logger.info("Initiating shutdown of flow service...");
logger.info("Flow Service shutdown started");
shutdown();
logger.info("Flow service termination completed.");
logger.info("Flow Service shutdown completed");
}
private void shutdown() {

View File

@ -30,3 +30,6 @@ java.arg.14=-Djava.awt.headless=true
#java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8002
java.arg.nodeNum=-DnodeNumber=1
# Disable Logback web shutdown hook using System property
java.arg.logbackShutdown=-DlogbackDisableServletContainerInitializer=true

View File

@ -15,6 +15,8 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>

View File

@ -30,3 +30,6 @@ java.arg.14=-Djava.awt.headless=true
#java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8003
java.arg.nodeNum=-DnodeNumber=2
# Disable Logback web shutdown hook using System property
java.arg.logbackShutdown=-DlogbackDisableServletContainerInitializer=true

View File

@ -15,6 +15,8 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>

View File

@ -28,3 +28,6 @@ java.arg.3=-Xmx512m
java.arg.14=-Djava.awt.headless=true
#java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8002
# Disable Logback web shutdown hook using System property
java.arg.logbackShutdown=-DlogbackDisableServletContainerInitializer=true

View File

@ -15,6 +15,8 @@
-->
<configuration scan="true" scanPeriod="30 seconds">
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook" />
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>