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

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

本文整理了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

  1. @Override
  2. public void restart() {
  3. Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
  4. try {
  5. if (jenkins != null) {
  6. jenkins.cleanUp();
  7. }
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  10. }
  11. System.exit(exitOnRestart);
  12. }
  13. }

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

  1. /**
  2. * In SMF managed environment, just commit a suicide and the service will be restarted by SMF.
  3. */
  4. @Override
  5. public void restart() throws IOException, InterruptedException {
  6. Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
  7. try {
  8. if (jenkins != null) {
  9. jenkins.cleanUp();
  10. }
  11. } catch (Exception e) {
  12. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  13. }
  14. System.exit(0);
  15. }

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

  1. @Override
  2. public void run() {
  3. try {
  4. ACL.impersonate(ACL.SYSTEM);
  5. LOGGER.info(String.format("Shutting down VM as requested by %s from %s",
  6. exitUser, exitAddr));
  7. // Wait 'til we have no active executors.
  8. doQuietDown(true, 0);
  9. // Make sure isQuietingDown is still true.
  10. if (isQuietingDown) {
  11. cleanUp();
  12. System.exit(0);
  13. }
  14. } catch (Exception e) {
  15. LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
  16. }
  17. }
  18. }.start();

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

  1. public void contextDestroyed(ServletContextEvent event) {
  2. try (ACLContext old = ACL.as(ACL.SYSTEM)) {
  3. Jenkins instance = Jenkins.getInstanceOrNull();
  4. try {
  5. if (instance != null) {
  6. instance.cleanUp();
  7. }
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  10. }
  11. terminated = true;
  12. Thread t = initThread;
  13. if (t != null && t.isAlive()) {
  14. LOGGER.log(Level.INFO, "Shutting down a Jenkins instance that was still starting up", new Throwable("reason"));
  15. t.interrupt();
  16. }
  17. // Logger is in the system classloader, so if we don't do this
  18. // the whole web app will never be undeployed.
  19. Logger.getLogger("").removeHandler(handler);
  20. } finally {
  21. JenkinsJVMAccess._setJenkinsJVM(false);
  22. }
  23. }

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

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

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

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

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

  1. @Override
  2. public void run() {
  3. boolean success = false;
  4. try {
  5. Jenkins instance = new Hudson(_home, context);
  6. // one last check to make sure everything is in order before we go live
  7. if (Thread.interrupted())
  8. throw new InterruptedException();
  9. context.setAttribute(APP, instance);
  10. BootFailure.getBootFailureFile(_home).delete();
  11. // at this point we are open for business and serving requests normally
  12. LOGGER.info("Jenkins is fully up and running");
  13. success = true;
  14. } catch (Error e) {
  15. new HudsonFailedToLoad(e).publish(context,_home);
  16. throw e;
  17. } catch (Exception e) {
  18. new HudsonFailedToLoad(e).publish(context,_home);
  19. } finally {
  20. Jenkins instance = Jenkins.getInstanceOrNull();
  21. if(!success && instance!=null)
  22. instance.cleanUp();
  23. }
  24. }
  25. };

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

  1. @Override
  2. public void restart() throws IOException, InterruptedException {
  3. Jenkins jenkins = Jenkins.getInstanceOrNull();
  4. try {
  5. if (jenkins != null) {
  6. jenkins.cleanUp();
  7. }
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  10. }
  11. File me = getHudsonWar();
  12. File home = me.getParentFile();
  13. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  14. StreamTaskListener task = new StreamTaskListener(baos);
  15. task.getLogger().println("Restarting a service");
  16. String exe = System.getenv("WINSW_EXECUTABLE");
  17. File executable;
  18. if (exe!=null) executable = new File(exe);
  19. else executable = new File(home, "hudson.exe");
  20. if (!executable.exists()) executable = new File(home, "jenkins.exe");
  21. // use restart! to run hudson/jenkins.exe restart in a separate process, so it doesn't kill itself
  22. int r = new LocalLauncher(task).launch().cmds(executable, "restart!")
  23. .stdout(task).pwd(home).join();
  24. if(r!=0)
  25. throw new IOException(baos.toString());
  26. }

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

  1. @Override
  2. public void restart() throws IOException, InterruptedException {
  3. Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
  4. try {
  5. if (jenkins != null) {
  6. jenkins.cleanUp();
  7. }
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  10. }
  11. // close all files upon exec, except stdin, stdout, and stderr
  12. int sz = LIBC.getdtablesize();
  13. for(int i=3; i<sz; i++) {
  14. int flags = LIBC.fcntl(i, F_GETFD);
  15. if(flags<0) continue;
  16. LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC);
  17. }
  18. // exec to self
  19. String exe = args.get(0);
  20. LIBC.execvp(exe, new StringArray(args.toArray(new String[args.size()])));
  21. throw new IOException("Failed to exec '"+exe+"' "+LIBC.strerror(Native.getLastError()));
  22. }

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

  1. /**
  2. * In SMF managed environment, just commit a suicide and the service will be restarted by SMF.
  3. */
  4. @Override
  5. public void restart() throws IOException, InterruptedException {
  6. Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
  7. try {
  8. if (jenkins != null) {
  9. jenkins.cleanUp();
  10. }
  11. } catch (Exception e) {
  12. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  13. }
  14. System.exit(0);
  15. }

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

  1. @Override
  2. public void run() {
  3. try {
  4. ACL.impersonate(ACL.SYSTEM);
  5. LOGGER.severe(String.format("Shutting down VM as requested by %s from %s",
  6. exitUser, exitAddr));
  7. // Wait 'til we have no active executors.
  8. doQuietDown(true, 0);
  9. // Make sure isQuietingDown is still true.
  10. if (isQuietingDown) {
  11. cleanUp();
  12. System.exit(0);
  13. }
  14. } catch (Exception e) {
  15. LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
  16. }
  17. }
  18. }.start();

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

  1. public void contextDestroyed(ServletContextEvent event) {
  2. try (ACLContext old = ACL.as(ACL.SYSTEM)) {
  3. Jenkins instance = Jenkins.getInstanceOrNull();
  4. try {
  5. if (instance != null) {
  6. instance.cleanUp();
  7. }
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  10. }
  11. terminated = true;
  12. Thread t = initThread;
  13. if (t != null && t.isAlive()) {
  14. LOGGER.log(Level.INFO, "Shutting down a Jenkins instance that was still starting up", new Throwable("reason"));
  15. t.interrupt();
  16. }
  17. // Logger is in the system classloader, so if we don't do this
  18. // the whole web app will never be undeployed.
  19. Logger.getLogger("").removeHandler(handler);
  20. } finally {
  21. JenkinsJVMAccess._setJenkinsJVM(false);
  22. }
  23. }

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

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

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

  1. @Override
  2. public void run() {
  3. boolean success = false;
  4. try {
  5. Jenkins instance = new Hudson(_home, context);
  6. // one last check to make sure everything is in order before we go live
  7. if (Thread.interrupted())
  8. throw new InterruptedException();
  9. context.setAttribute(APP, instance);
  10. BootFailure.getBootFailureFile(_home).delete();
  11. // at this point we are open for business and serving requests normally
  12. LOGGER.info("Jenkins is fully up and running");
  13. success = true;
  14. } catch (Error e) {
  15. new HudsonFailedToLoad(e).publish(context,_home);
  16. throw e;
  17. } catch (Exception e) {
  18. new HudsonFailedToLoad(e).publish(context,_home);
  19. } finally {
  20. Jenkins instance = Jenkins.getInstanceOrNull();
  21. if(!success && instance!=null)
  22. instance.cleanUp();
  23. }
  24. }
  25. };

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

  1. @Override
  2. public void restart() throws IOException, InterruptedException {
  3. Jenkins jenkins = Jenkins.getInstanceOrNull();
  4. try {
  5. if (jenkins != null) {
  6. jenkins.cleanUp();
  7. }
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  10. }
  11. File me = getHudsonWar();
  12. File home = me.getParentFile();
  13. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  14. StreamTaskListener task = new StreamTaskListener(baos);
  15. task.getLogger().println("Restarting a service");
  16. String exe = System.getenv("WINSW_EXECUTABLE");
  17. File executable;
  18. if (exe!=null) executable = new File(exe);
  19. else executable = new File(home, "hudson.exe");
  20. if (!executable.exists()) executable = new File(home, "jenkins.exe");
  21. // use restart! to run hudson/jenkins.exe restart in a separate process, so it doesn't kill itself
  22. int r = new LocalLauncher(task).launch().cmds(executable, "restart!")
  23. .stdout(task).pwd(home).join();
  24. if(r!=0)
  25. throw new IOException(baos.toString());
  26. }

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

  1. jenkins.cleanUp();
  2. ExtensionList.clearLegacyInstances();
  3. DescriptorExtensionList.clearLegacyInstances();

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

  1. jenkins.cleanUp();
  2. ExtensionList.clearLegacyInstances();
  3. DescriptorExtensionList.clearLegacyInstances();

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

  1. /**
  2. * Shutdown the system.
  3. * @since 1.161
  4. */
  5. @CLIMethod(name="shutdown")
  6. @RequirePOST
  7. public void doExit( StaplerRequest req, StaplerResponse rsp ) throws IOException {
  8. checkPermission(ADMINISTER);
  9. LOGGER.severe(String.format("Shutting down VM as requested by %s from %s",
  10. getAuthentication().getName(), req!=null?req.getRemoteAddr():"???"));
  11. if (rsp!=null) {
  12. rsp.setStatus(HttpServletResponse.SC_OK);
  13. rsp.setContentType("text/plain");
  14. try (PrintWriter w = rsp.getWriter()) {
  15. w.println("Shutting down");
  16. }
  17. }
  18. cleanUp();
  19. System.exit(0);
  20. }

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

  1. jenkins.cleanUp();
  2. ExtensionList.clearLegacyInstances();
  3. DescriptorExtensionList.clearLegacyInstances();

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

  1. @Override
  2. public void restart() throws IOException, InterruptedException {
  3. Jenkins jenkins = Jenkins.getInstanceOrNull(); // guard against repeated concurrent calls to restart
  4. try {
  5. if (jenkins != null) {
  6. jenkins.cleanUp();
  7. }
  8. } catch (Exception e) {
  9. LOGGER.log(Level.SEVERE, "Failed to clean up. Restart will continue.", e);
  10. }
  11. // close all files upon exec, except stdin, stdout, and stderr
  12. int sz = LIBC.getdtablesize();
  13. for(int i=3; i<sz; i++) {
  14. int flags = LIBC.fcntl(i, F_GETFD);
  15. if(flags<0) continue;
  16. LIBC.fcntl(i, F_SETFD,flags| FD_CLOEXEC);
  17. }
  18. // exec to self
  19. String exe = args.get(0);
  20. LIBC.execvp(exe, new StringArray(args.toArray(new String[args.size()])));
  21. throw new IOException("Failed to exec '"+exe+"' "+LIBC.strerror(Native.getLastError()));
  22. }

相关文章

Jenkins类方法