Skip to content

Commit

Permalink
remove dependency on tomcat APis from _GrailsRun
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed May 17, 2012
1 parent 2a77408 commit 62cd51f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
* @since 2.1
*/
public class TomcatKillSwitch implements Runnable {

private static boolean active = true;


public static final String TOMCAT_KILL_SWITCH_ACTIVE = "TomcatKillSwitch.active";

private Tomcat tomcat;
private int serverPort;
Expand All @@ -25,11 +26,11 @@ public TomcatKillSwitch(Tomcat tomcat, int serverPort) {
}

public static boolean isActive() {
return active;
return Boolean.getBoolean("TomcatKillSwitch.active");
}

public void run() {
active = true;
System.setProperty("TomcatKillSwitch.active", "true");
int killListenerPort = serverPort + 1;
ServerSocket serverSocket = createKillSwitch(killListenerPort);
if (serverSocket != null) {
Expand All @@ -38,7 +39,7 @@ public void run() {
try {
tomcat.stop();
tomcat.destroy();
active = false;
System.setProperty(TOMCAT_KILL_SWITCH_ACTIVE, "false");
} catch (LifecycleException e) {
System.err.println("Error stopping Tomcat: " + e.getMessage());
System.exit(1);
Expand Down
4 changes: 2 additions & 2 deletions scripts/_GrailsRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import java.net.ServerSocket
import org.codehaus.groovy.grails.cli.ScriptExitException
import org.codehaus.groovy.grails.cli.interactive.InteractiveMode
import org.codehaus.groovy.grails.compiler.GrailsProjectWatcher
import org.grails.plugins.tomcat.TomcatKillSwitch


/**
* Gant script that executes Grails using an embedded server.
Expand Down Expand Up @@ -241,7 +241,7 @@ target(keepServerAlive: "Idles the script, ensuring that the server stays runnin
killFile.delete()
}

while (keepRunning && TomcatKillSwitch.active) {
while (keepRunning && Boolean.getBoolean("TomcatKillSwitch.active")) {
sleep(recompileFrequency * 1000)

// Check whether the kill file exists. This is a hack for the
Expand Down

0 comments on commit 62cd51f

Please sign in to comment.