jenkins.model.Jenkins.cleanUp()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(201)

本文整理了Java中jenkins.model.Jenkins.cleanUp()方法的一些代码示例,展示了Jenkins.cleanUp()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.cleanUp()方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:cleanUp

Jenkins.cleanUp介绍

[英]Called to shut down the system.
[中]调用以关闭系统。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override
  public void restart() {
    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(exitOnRestart);
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * In SMF managed environment, just commit a suicide and the service will be restarted by SMF.
 */
@Override
public void restart() throws IOException, InterruptedException {
  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);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
  public void run() {
    try {
      ACL.impersonate(ACL.SYSTEM);
      LOGGER.info(String.format("Shutting down VM as requested by %s from %s",
                    exitUser, exitAddr));
      // Wait 'til we have no active executors.
      doQuietDown(true, 0);
      // Make sure isQuietingDown is still true.
      if (isQuietingDown) {
        cleanUp();
        System.exit(0);
      }
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
    }
  }
}.start();

代码示例来源:origin: jenkinsci/jenkins

public void contextDestroyed(ServletContextEvent event) {
  try (ACLContext old = ACL.as(ACL.SYSTEM)) {
    Jenkins instance = Jenkins.getInstanceOrNull();
    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"));
      t.interrupt();
    }
    // Logger is in the system classloader, so if we don't do this
    // the whole web app will never be undeployed.
    Logger.getLogger("").removeHandler(handler);
  } finally {
    JenkinsJVMAccess._setJenkinsJVM(false);
  }
}

代码示例来源:origin: jenkinsci/jenkins

Jenkins.getInstance().cleanUp();
  System.exit(0);
} catch (InterruptedException e) {

代码示例来源:origin: jenkinsci/jenkins

@Override
  public void run() {
    try {
      ACL.impersonate(ACL.SYSTEM);
      LOGGER.info(String.format("Shutting down VM as requested by %s from %s",
          getAuthentication().getName(), req != null ? req.getRemoteAddr() : "???"));
      cleanUp();
      System.exit(0);
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
    }
  }
}.start();

代码示例来源:origin: jenkinsci/jenkins

@Override
  public void run() {
    boolean success = false;
    try {
      Jenkins instance = new Hudson(_home, context);
      // one last check to make sure everything is in order before we go live
      if (Thread.interrupted())
        throw new InterruptedException();
      context.setAttribute(APP, instance);
      BootFailure.getBootFailureFile(_home).delete();
      // at this point we are open for business and serving requests normally
      LOGGER.info("Jenkins is fully up and running");
      success = true;
    } catch (Error e) {
      new HudsonFailedToLoad(e).publish(context,_home);
      throw e;
    } catch (Exception e) {
      new HudsonFailedToLoad(e).publish(context,_home);
    } finally {
      Jenkins instance = Jenkins.getInstanceOrNull();
      if(!success && instance!=null)
        instance.cleanUp();
    }
  }
};

代码示例来源:origin: jenkinsci/jenkins

@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();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamTaskListener task = new StreamTaskListener(baos);
  task.getLogger().println("Restarting a service");
  String exe = System.getenv("WINSW_EXECUTABLE");
  File executable;
  if (exe!=null)   executable = new File(exe);
  else            executable = new File(home, "hudson.exe");
  if (!executable.exists())   executable = new File(home, "jenkins.exe");
  // use restart! to run hudson/jenkins.exe restart in a separate process, so it doesn't kill itself
  int r = new LocalLauncher(task).launch().cmds(executable, "restart!")
      .stdout(task).pwd(home).join();
  if(r!=0)
    throw new IOException(baos.toString());
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void restart() throws IOException, InterruptedException {
  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();
  for(int i=3; i<sz; i++) {
    int flags = LIBC.fcntl(i, F_GETFD);
    if(flags<0) continue;
    LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC);
  }
  // exec to self
  String exe = args.get(0);
  LIBC.execvp(exe, new StringArray(args.toArray(new String[args.size()])));
  throw new IOException("Failed to exec '"+exe+"' "+LIBC.strerror(Native.getLastError()));
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * In SMF managed environment, just commit a suicide and the service will be restarted by SMF.
 */
@Override
public void restart() throws IOException, InterruptedException {
  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);
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Override
  public void run() {
    try {
      ACL.impersonate(ACL.SYSTEM);
      LOGGER.severe(String.format("Shutting down VM as requested by %s from %s",
                    exitUser, exitAddr));
      // Wait 'til we have no active executors.
      doQuietDown(true, 0);
      // Make sure isQuietingDown is still true.
      if (isQuietingDown) {
        cleanUp();
        System.exit(0);
      }
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
    }
  }
}.start();

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

public void contextDestroyed(ServletContextEvent event) {
  try (ACLContext old = ACL.as(ACL.SYSTEM)) {
    Jenkins instance = Jenkins.getInstanceOrNull();
    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"));
      t.interrupt();
    }
    // Logger is in the system classloader, so if we don't do this
    // the whole web app will never be undeployed.
    Logger.getLogger("").removeHandler(handler);
  } finally {
    JenkinsJVMAccess._setJenkinsJVM(false);
  }
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

Jenkins.getInstance().cleanUp();
  System.exit(0);
} catch (InterruptedException e) {

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Override
  public void run() {
    boolean success = false;
    try {
      Jenkins instance = new Hudson(_home, context);
      // one last check to make sure everything is in order before we go live
      if (Thread.interrupted())
        throw new InterruptedException();
      context.setAttribute(APP, instance);
      BootFailure.getBootFailureFile(_home).delete();
      // at this point we are open for business and serving requests normally
      LOGGER.info("Jenkins is fully up and running");
      success = true;
    } catch (Error e) {
      new HudsonFailedToLoad(e).publish(context,_home);
      throw e;
    } catch (Exception e) {
      new HudsonFailedToLoad(e).publish(context,_home);
    } finally {
      Jenkins instance = Jenkins.getInstanceOrNull();
      if(!success && instance!=null)
        instance.cleanUp();
    }
  }
};

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@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();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  StreamTaskListener task = new StreamTaskListener(baos);
  task.getLogger().println("Restarting a service");
  String exe = System.getenv("WINSW_EXECUTABLE");
  File executable;
  if (exe!=null)   executable = new File(exe);
  else            executable = new File(home, "hudson.exe");
  if (!executable.exists())   executable = new File(home, "jenkins.exe");
  // use restart! to run hudson/jenkins.exe restart in a separate process, so it doesn't kill itself
  int r = new LocalLauncher(task).launch().cmds(executable, "restart!")
      .stdout(task).pwd(home).join();
  if(r!=0)
    throw new IOException(baos.toString());
}

代码示例来源:origin: io.jenkins.jenkinsfile-runner/setup

jenkins.cleanUp();
ExtensionList.clearLegacyInstances();
DescriptorExtensionList.clearLegacyInstances();

代码示例来源:origin: jenkinsci/jenkinsfile-runner

jenkins.cleanUp();
ExtensionList.clearLegacyInstances();
DescriptorExtensionList.clearLegacyInstances();

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * Shutdown the system.
 * @since 1.161
 */
@CLIMethod(name="shutdown")
@RequirePOST
public void doExit( StaplerRequest req, StaplerResponse rsp ) throws IOException {
  checkPermission(ADMINISTER);
  LOGGER.severe(String.format("Shutting down VM as requested by %s from %s",
      getAuthentication().getName(), req!=null?req.getRemoteAddr():"???"));
  if (rsp!=null) {
    rsp.setStatus(HttpServletResponse.SC_OK);
    rsp.setContentType("text/plain");
    try (PrintWriter w = rsp.getWriter()) {
      w.println("Shutting down");
    }
  }
  cleanUp();
  System.exit(0);
}

代码示例来源:origin: jenkinsci/jenkins-test-harness

jenkins.cleanUp();
ExtensionList.clearLegacyInstances();
DescriptorExtensionList.clearLegacyInstances();

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Override
public void restart() throws IOException, InterruptedException {
  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();
  for(int i=3; i<sz; i++) {
    int flags = LIBC.fcntl(i, F_GETFD);
    if(flags<0) continue;
    LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC);
  }
  // exec to self
  String exe = args.get(0);
  LIBC.execvp(exe, new StringArray(args.toArray(new String[args.size()])));
  throw new IOException("Failed to exec '"+exe+"' "+LIBC.strerror(Native.getLastError()));
}

相关文章

微信公众号

最新文章

更多

Jenkins类方法