Permalink
Browse files

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

[JENKINS-32820, JENKINS-42164] - Windows service restart does not retain the build queue
  • Loading branch information...
oleg-nenashev committed Feb 18, 2017
2 parents 1763e64 + 08a993d commit 4ab693846ca7a4aa112959a2e92688c3fb9122c3
@@ -375,10 +375,16 @@ public FileAndDescription getHomeDir(ServletContextEvent event) {
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 @@
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 @@
*/
@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.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 UnixLifecycle() throws IOException {
@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 void verifyRestartable() throws RestartNotSupportedException {
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 void rewriteHudsonWar(File by) throws IOException {
@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();

0 comments on commit 4ab6938

Please sign in to comment.