Skip to content

Commit

Permalink
[FIXED JENKINS-6594] added shutdown and safe-shutdown command
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Aug 10, 2011
1 parent a77c21d commit 7aad07c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -92,6 +92,9 @@
<li class=rfe>
Added two CLI commands to manipulate job by its XML definition.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-8797">issue 8797</a>)
<li class=rfe>
Added two CLI commands to shutdown Jenkins
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-6594">issue 6594</a>)
<li class=rfe>
Fixed unclear text for Tabs with no jobs
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9330">issue 9330</a>)
Expand Down
16 changes: 10 additions & 6 deletions core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -3038,15 +3038,18 @@ public void run() {
* Shutdown the system.
* @since 1.161
*/
@CLIMethod(name="shutdown")
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.getRemoteAddr()));
rsp.setStatus(HttpServletResponse.SC_OK);
rsp.setContentType("text/plain");
PrintWriter w = rsp.getWriter();
w.println("Shutting down");
w.close();
getAuthentication().getName(), req!=null?req.getRemoteAddr():"???"));
if (rsp!=null) {
rsp.setStatus(HttpServletResponse.SC_OK);
rsp.setContentType("text/plain");
PrintWriter w = rsp.getWriter();
w.println("Shutting down");
w.close();
}

System.exit(0);
}
Expand All @@ -3056,6 +3059,7 @@ public void doExit( StaplerRequest req, StaplerResponse rsp ) throws IOException
* Shutdown the system safely.
* @since 1.332
*/
@CLIMethod(name="safe-shutdown")
public HttpResponse doSafeExit(StaplerRequest req) throws IOException {
checkPermission(ADMINISTER);
isQuietingDown = true;
Expand Down

0 comments on commit 7aad07c

Please sign in to comment.