Permalink
Browse files

remove dependency on tomcat APis from _GrailsRun

  • Loading branch information...
1 parent 2a77408 commit 62cd51f8051f86f4201393637253cef470bf0e86 @graemerocher graemerocher committed May 17, 2012
View
11 grails-plugin-tomcat/src/main/groovy/org/grails/plugins/tomcat/TomcatKillSwitch.java
@@ -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;
@@ -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) {
@@ -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);
View
4 scripts/_GrailsRun.groovy
@@ -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.
@@ -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

0 comments on commit 62cd51f

Please sign in to comment.