提交 4ab69384 编写于 作者: O Oleg Nenashev 提交者: GitHub

Merge pull request #2746 from oleg-nenashev/bug/JENKINS-32820

[JENKINS-32820, JENKINS-42164] - Windows service restart does not retain the build queue
......@@ -375,10 +375,16 @@ public class WebAppMain implements ServletContextListener {
public void contextDestroyed(ServletContextEvent event) {
try (ACLContext old = ACL.as(ACL.SYSTEM)) {
terminated = true;
Jenkins instance = Jenkins.getInstanceOrNull();
if (instance != null)
instance.cleanUp();
try {
if (instance != null) {
instance.cleanUp();
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
}
terminated = true;
Thread t = initThread;
if (t != null && t.isAlive()) {
LOGGER.log(Level.INFO, "Shutting down a Jenkins instance that was still starting up", new Throwable("reason"));
......
......@@ -26,6 +26,8 @@ package hudson.lifecycle;
import jenkins.model.Jenkins;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* {@link Lifecycle} for Hudson installed as SMF service.
......@@ -38,9 +40,16 @@ public class SolarisSMFLifecycle extends Lifecycle {
*/
@Override
public void restart() throws IOException, InterruptedException {
Jenkins h = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
if (h != null)
h.cleanUp();
Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
try {
if (jenkins != null) {
jenkins.cleanUp();
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
}
System.exit(0);
}
private static final Logger LOGGER = Logger.getLogger(SolarisSMFLifecycle.class.getName());
}
......@@ -28,6 +28,8 @@ import com.sun.jna.Native;
import com.sun.jna.StringArray;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import static hudson.util.jna.GNUCLibrary.*;
......@@ -65,9 +67,14 @@ public class UnixLifecycle extends Lifecycle {
@Override
public void restart() throws IOException, InterruptedException {
Jenkins h = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
if (h != null)
h.cleanUp();
Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
try {
if (jenkins != null) {
jenkins.cleanUp();
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
}
// close all files upon exec, except stdin, stdout, and stderr
int sz = LIBC.getdtablesize();
......@@ -96,4 +103,6 @@ public class UnixLifecycle extends Lifecycle {
if (args==null)
throw new RestartNotSupportedException("Failed to obtain the command line arguments of the process",failedToObtainArgs);
}
private static final Logger LOGGER = Logger.getLogger(UnixLifecycle.class.getName());
}
......@@ -117,6 +117,15 @@ public class WindowsServiceLifecycle extends Lifecycle {
@Override
public void restart() throws IOException, InterruptedException {
Jenkins jenkins = Jenkins.getInstanceOrNull();
try {
if (jenkins != null) {
jenkins.cleanUp();
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
}
File me = getHudsonWar();
File home = me.getParentFile();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册