mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-21 15:55:40 +00:00
Jenkins should terminate cleanly on SIGTERM (#6230)
This commit is contained in:
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.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user