Commit fa7d8a95 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added posibility to shutdown server from the admin console. JM-44


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@740 b35dd754-fafc-0310-a699-88a17e54d16e
parent e1872a19
...@@ -316,6 +316,23 @@ public class XMPPServer { ...@@ -316,6 +316,23 @@ public class XMPPServer {
} }
} }
/**
* Restarts the server and all it's modules only if the server is restartable. Otherwise do
* nothing.
*/
public void restart() {
if (isStandAlone() && isRestartable()) {
try {
Class wrapperClass = Class.forName(WRAPPER_CLASSNAME);
Method restartMethod = wrapperClass.getMethod("restart", null);
restartMethod.invoke(null, null);
}
catch (Exception e) {
Log.error("Could not restart container", e);
}
}
}
/** /**
* Stops the server only if running in standalone mode. Do nothing if the server is running * Stops the server only if running in standalone mode. Do nothing if the server is running
* inside of another server. * inside of another server.
...@@ -348,7 +365,7 @@ public class XMPPServer { ...@@ -348,7 +365,7 @@ public class XMPPServer {
return setupMode; return setupMode;
} }
private boolean isRestartable() { public boolean isRestartable() {
boolean restartable = false; boolean restartable = false;
try { try {
restartable = Class.forName(WRAPPER_CLASSNAME) != null; restartable = Class.forName(WRAPPER_CLASSNAME) != null;
...@@ -366,7 +383,7 @@ public class XMPPServer { ...@@ -366,7 +383,7 @@ public class XMPPServer {
* *
* @return true if the server is running in standalone mode. * @return true if the server is running in standalone mode.
*/ */
private boolean isStandAlone() { public boolean isStandAlone() {
boolean standalone = false; boolean standalone = false;
try { try {
standalone = Class.forName(STARTER_CLASSNAME) != null; standalone = Class.forName(STARTER_CLASSNAME) != null;
...@@ -558,6 +575,10 @@ public class XMPPServer { ...@@ -558,6 +575,10 @@ public class XMPPServer {
* Makes a best effort attempt to shutdown the server * Makes a best effort attempt to shutdown the server
*/ */
private void shutdownServer() { private void shutdownServer() {
// If we don't have modules then the server has already been shutdown
if (modules.isEmpty()) {
return;
}
// Get all modules and stop and destroy them // Get all modules and stop and destroy them
for (Module module : modules.values()) { for (Module module : modules.values()) {
module.stop(); module.stop();
......
...@@ -126,30 +126,30 @@ public class WebManager extends WebBean { ...@@ -126,30 +126,30 @@ public class WebManager extends WebBean {
} }
/** /**
* Restarts the container then sleeps for 3 seconds. * Restarts the server then sleeps for 3 seconds.
*/ */
/*public void restart(XMPPServer server) { public void restart() {
try { try {
server.restart(); getXMPPServer().restart();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e);
} }
sleep(); sleep();
}*/ }
/** /**
* Stops the server then sleeps for 3 seconds. * Stops the server then sleeps for 3 seconds.
*/ */
/*public void stop(XMPPServer server) { public void stop() {
try { try {
server.stop(); getXMPPServer().stop();
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e);
} }
sleep(); sleep();
}*/ }
public WebManager getManager() { public WebManager getManager() {
return this; return this;
...@@ -162,10 +162,6 @@ public class WebManager extends WebBean { ...@@ -162,10 +162,6 @@ public class WebManager extends WebBean {
} }
} }
public String getErrorPage() {
return "error-serverdown.jsp";
}
public boolean isServerRunning() { public boolean isServerRunning() {
if (getPresenceManager() == null || if (getPresenceManager() == null ||
getXMPPServer() == null) { getXMPPServer() == null) {
......
<%-- <%--
- $RCSfile$ - $RCSfile$
- $Revision$ - $Revision$
- $Date$ - $Date$
--%> --%>
<%@ page import="org.jivesoftware.admin.AdminConsole"%>
<%@ include file="header.jsp" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<% // Title of this page and breadcrumbs <jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
String title = "Jive Messenger Server Down";
String[][] breadcrumbs = { <%-- Define Administration Bean --%>
{ "Home", "index.jsp" }, <jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
{ title, "error-serverdown.jsp" } <% admin.init(request, response, session, application, out ); %>
};
<% String path = request.getContextPath();
// Title of this page
String title = AdminConsole.getAppName() + " Server Down";
pageinfo.setTitle(title);
%> %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><%= AdminConsole.getAppName() %> Admin Console<%= (pageinfo.getTitle() != null ? (": "+pageinfo.getTitle()) : "") %></title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="<%= path %>/style/global.css">
</head>
<body>
<div id="jive-header">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td>
<img src="<%= path %>/<%= AdminConsole.getLogoImage() %>" border="0" alt="<%= AdminConsole.getAppName() %> Admin Console">
</td>
<td align="right">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>&nbsp;</td>
<td class="info">
<nobr><%= AdminConsole.getAppName() %> <%= AdminConsole.getVersionString() %></nobr>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div id="jive-main">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tbody>
<tr valign="top">
<td width="1%">
<div id="jive-sidebar">
<img src="<%= path %>/images/blank.gif" width="5" height="1" border="0" alt="">
</div>
</td>
<td width="99%" id="jive-content">
<jsp:include page="title.jsp" flush="true" />
<p>
<%= AdminConsole.getAppName() %> is currently down.
To continue:
</p>
<ol>
<li>
Start the server.
</li>
<li>
<a href="index.jsp">Login to the admin console</a>.
</li>
</ol>
<p> </td>
Jive Messenger is currently down. Please see the </tr>
<a href="server-status.jsp">server status</a> page for more details. </tbody>
</p> </table>
</div>
<jsp:include page="bottom.jsp" flush="true" /> </body>
\ No newline at end of file </html>
\ No newline at end of file
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
java.text.*, java.text.*,
org.jivesoftware.admin.AdminPageBean, org.jivesoftware.admin.AdminPageBean,
org.jivesoftware.admin.AdminConsole" org.jivesoftware.admin.AdminConsole"
%> %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
...@@ -41,6 +40,18 @@ ...@@ -41,6 +40,18 @@
<% // Get parameters // <% // Get parameters //
boolean serverOn = (webManager.getXMPPServer() != null); boolean serverOn = (webManager.getXMPPServer() != null);
boolean stop = request.getParameter("stop") != null;
boolean restart = request.getParameter("restart") != null;
// Handle stops & restarts
if (stop) {
response.sendRedirect("server-stopped.jsp");
return;
}
else if (restart) {
response.sendRedirect("server-stopped.jsp?restart=Restart");
return;
}
%> %>
<% // Title of this page and breadcrumbs <% // Title of this page and breadcrumbs
...@@ -58,6 +69,15 @@ Below are properties for this server. Click the "Edit Properties" button below t ...@@ -58,6 +69,15 @@ Below are properties for this server. Click the "Edit Properties" button below t
some of the server settings. Some settings can not be changed. some of the server settings. Some settings can not be changed.
</p> </p>
<script lang="JavaScript" type="text/javascript">
var checked = false;
function checkClick() {
if (checked) { return false; }
else { checked = true; return true; }
}
</script>
<form action="index.jsp" onsubmit="return checkClick();">
<div class="jive-table"> <div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%"> <table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead> <thead>
...@@ -97,6 +117,14 @@ some of the server settings. Some settings can not be changed. ...@@ -97,6 +117,14 @@ some of the server settings. Some settings can not be changed.
<% } %> <% } %>
started <%= formatter.format(webManager.getXMPPServer().getServerInfo().getLastStarted()) %> started <%= formatter.format(webManager.getXMPPServer().getServerInfo().getLastStarted()) %>
<% if (webManager.getXMPPServer().isStandAlone()){ %>
&nbsp;&nbsp;<input type="submit" value="Stop" name="stop" <%= ((serverOn) ? "" : "disabled") %>>
<% if (webManager.getXMPPServer().isRestartable()){ %>
&nbsp;&nbsp;<input type="submit" value="Restart" name="restart" <%= ((serverOn) ? "" : "disabled") %>>
<% } %>
<% } %>
</td> </td>
</tr> </tr>
...@@ -204,6 +232,7 @@ some of the server settings. Some settings can not be changed. ...@@ -204,6 +232,7 @@ some of the server settings. Some settings can not be changed.
</tbody> </tbody>
</table> </table>
</div> </div>
</form>
<br> <br>
<form action="server-props.jsp"> <form action="server-props.jsp">
......
...@@ -95,7 +95,7 @@ a server restart. ...@@ -95,7 +95,7 @@ a server restart.
<tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td> <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label"> <td class="jive-icon-label">
Service properties edited successfully. You must <b>restart</b> the server in order for Service properties edited successfully. You must <b>restart</b> the server in order for
the changes to take effect. the changes to take effect (see <a href="index.jsp">Server Status</a>).
</td></tr> </td></tr>
</tbody> </tbody>
</table> </table>
......
...@@ -122,7 +122,7 @@ Use the form below to edit server properties. ...@@ -122,7 +122,7 @@ Use the form below to edit server properties.
<tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td> <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label"> <td class="jive-icon-label">
Server properties updated successfully. You'll need to <b>restart</b> the server to have Server properties updated successfully. You'll need to <b>restart</b> the server to have
the changes take effect. the changes take effect (see <a href="index.jsp">Server Status</a>).
</td></tr> </td></tr>
</tbody> </tbody>
</table> </table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment