|
|
@ -23,6 +23,8 @@ import java.lang.reflect.Constructor; |
|
|
|
import java.lang.reflect.InvocationHandler; |
|
|
|
import java.lang.reflect.InvocationHandler; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.lang.reflect.Proxy; |
|
|
|
import java.lang.reflect.Proxy; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
|
@ -30,6 +32,8 @@ public class LoggingSignalHandler { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(LoggingSignalHandler.class); |
|
|
|
private static final Logger log = LoggerFactory.getLogger(LoggingSignalHandler.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final List<String> SIGNALS = Arrays.asList("TERM", "INT", "HUP"); |
|
|
|
|
|
|
|
|
|
|
|
private final Constructor<?> signalConstructor; |
|
|
|
private final Constructor<?> signalConstructor; |
|
|
|
private final Class<?> signalHandlerClass; |
|
|
|
private final Class<?> signalHandlerClass; |
|
|
|
private final Class<?> signalClass; |
|
|
|
private final Class<?> signalClass; |
|
|
@ -61,9 +65,11 @@ public class LoggingSignalHandler { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void register() throws ReflectiveOperationException { |
|
|
|
public void register() throws ReflectiveOperationException { |
|
|
|
Map<String, Object> jvmSignalHandlers = new ConcurrentHashMap<>(); |
|
|
|
Map<String, Object> jvmSignalHandlers = new ConcurrentHashMap<>(); |
|
|
|
register("TERM", jvmSignalHandlers); |
|
|
|
|
|
|
|
register("INT", jvmSignalHandlers); |
|
|
|
for (String signal : SIGNALS) { |
|
|
|
register("HUP", jvmSignalHandlers); |
|
|
|
register(signal, jvmSignalHandlers); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.info("Registered signal handlers for " + String.join(", ", SIGNALS)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Object createSignalHandler(final Map<String, Object> jvmSignalHandlers) { |
|
|
|
private Object createSignalHandler(final Map<String, Object> jvmSignalHandlers) { |
|
|
|