Skip to content
Snippets Groups Projects
Commit 5b8761c1 authored by Vincent Massol's avatar Vincent Massol
Browse files

XWIKI-11008: Allow stopping running XWiki instances when starting a new instance

* Fix another bug...
parent 532f1a9a
No related branches found
No related tags found
No related merge requests found
......@@ -250,7 +250,9 @@ private void startXWiki() throws Exception
{
File dir = new File(getExecutionDirectory());
if (dir.exists()) {
this.startedProcessHandler = executeCommand(getDefaultStartCommand(getPort(), getStopPort(), getRMIPort()));
String startCommand = getDefaultStartCommand(getPort(), getStopPort(), getRMIPort());
LOGGER.debug("Executing command: [{}]", startCommand);
this.startedProcessHandler = executeCommand(startCommand);
} else {
throw new Exception(String.format("Invalid directory from where to start XWiki [%s]. If you're starting "
+ "a functional test from your IDE, make sure to either have started an XWiki instance beforehand or "
......@@ -333,6 +335,8 @@ public Response isXWikiStarted(String url, int timeout) throws Exception
public void stop() throws Exception
{
LOGGER.debug("Checking if we need to stop the XWiki server running at [{}]...", getURL());
// Do not try to stop XWiki if we've not been successful in starting it!
if (!this.hasXWikiBeenStartedProperly) {
return;
......@@ -340,8 +344,9 @@ public void stop() throws Exception
// Stop XWiki if it was started by start()
if (!this.wasStarted) {
DefaultExecuteResultHandler stopProcessHandler =
executeCommand(getDefaultStopCommand(getPort(), getStopPort()));
String stopCommand = getDefaultStopCommand(getPort(), getStopPort());
LOGGER.debug("Executing command: [{}]", stopCommand);
DefaultExecuteResultHandler stopProcessHandler = executeCommand(stopCommand);
// First wait for the stop process to have stopped, waiting a max of 5 minutes!
// It's going to stop the start process...
......@@ -537,6 +542,7 @@ private String getDefaultStopCommand(int port, int stopPort)
stopCommand = String.format("bash stop_xwiki.sh -p %s -sp %s", port, stopPort);
}
} else {
stopCommand = stopCommand.replaceFirst(DEFAULT_PORT, String.valueOf(port));
stopCommand = stopCommand.replaceFirst(DEFAULT_STOPPORT, String.valueOf(stopPort));
}
......
......@@ -114,7 +114,7 @@ XWIKI_OPTS="$XWIKI_OPTS -Djetty.home=$JETTY_HOME"
[ ! -e $XWIKI_LOCK_FILE ] && echo "Lock [${XWIKI_LOCK_FILE}] missing" && exit 0;
echo 'Attempting to stop XWiki cleanly...';
echo 'Attempting to stop XWiki cleanly on port ${JETTY_PORT}...';
java $XWIKI_OPTS -jar $JETTY_HOME/start.jar --stop
waitForLockDeletion $XWIKI_LOCK_FILE && exit 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment