Skip to content
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
(cherry picked from commit 4ab6938)
  • Loading branch information...
oleg-nenashev authored and olivergondza committed Feb 18, 2017
1 parent e2a8c0e commit 5f655a59b6d263061d6c5c1d05ac8d5d1d1d391f
@@ -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 5f655a5

Please sign in to comment.
You can’t perform that action at this time.