Jenkins should terminate cleanly on SIGTERM (#6230)

This commit is contained in:
Basil Crow authored and GitHub committed 2022-01-31 07:51:35 -08:00
1 parent 405e977797
commit 1a42044347
1 file changed
+13
@@ -54,6 +54,19 @@ import org.apache.commons.io.FileUtils;
public abstract class Lifecycle implements ExtensionPoint {
private static Lifecycle INSTANCE = null;
public Lifecycle() {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Jenkins jenkins = Jenkins.getInstanceOrNull();
if (jenkins != null) {
try {
jenkins.cleanUp();
} catch (Throwable t) {
LOGGER.log(Level.SEVERE, "Failed to clean up. Shutdown will continue.", t);
}
}
}));
}
/**
* Gets the singleton instance.
*