Author: doogie
Date: Wed Oct 17 10:56:23 2007
New Revision: 585607
URL:
http://svn.apache.org/viewvc?rev=585607&view=revLog:
Implement tri-state status management. The server status can now be
"Starting", "Running", or "Stopped". I didn't implement "Stopping",
because it never was a problem for me. Closes
https://issues.apache.org/jira/browse/OFBIZ-1297Modified:
ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java
Modified: ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java?rev=585607&r1=585606&r2=585607&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java (original)
+++ ofbiz/trunk/framework/base/src/start/org/ofbiz/base/start/Start.java Wed Oct 17 10:56:23 2007
@@ -46,6 +46,8 @@
private ClassLoader classloader = null;
private ServerSocket serverSocket = null;
private Thread serverThread = null;
+ private boolean serverStarted = false;
+ private boolean serverStopping = false;
private boolean serverRunning = true;
private List loaders = null;
private Config config = null;
@@ -134,12 +136,18 @@
return "FAIL";
} else {
if (command.equals(Start.SHUTDOWN_COMMAND)) {
- System.out.println("Shutdown initiated from: " + client.getInetAddress().getHostAddress() + ":" + client.getPort());
- serverRunning = false;
+ if (serverStopping) return "IN-PROGRESS";
+ Thread t = new Thread() {
+ public void run() {
+ shutdownServer();
+ }
+ };
+ t.start();
+ return "OK";
} else if (command.equals(Start.STATUS_COMMAND)) {
- return serverRunning ? "Running" : "Stopped";
+ return serverStopping ? "Stopping" : serverStarted ? "Running" : "Starting";
}
- return "OK";
+ return "FAIL";
}
} else {
return "FAIL";
@@ -261,6 +269,7 @@
System.exit(99);
}
}
+ serverStarted = true;
}
private void setShutdownHook() {
@@ -287,6 +296,8 @@
}
private void shutdownServer() {
+ if (serverStopping) return;
+ serverStopping = true;
if (loaders != null && loaders.size() > 0) {
Iterator i = loaders.iterator();
while (i.hasNext()) {