gitHash = ""
gitBranch = ""
+
+ jalviewjsServer = ""
}
def JAVA_INTEGER_VERSION
dependsOn jalviewjsBuildSite
}
-task jalviewjsServer {
- //dependsOn jalviewjsBuildSite
-
+def jalviewjsServer = null
+task jalviewjsServerStart {
doLast {
- SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
- def port = Integer.valueOf(jalviewjs_server_port)
- def start = port
- def running = false
- HttpFileServer server
-println "server wait = ${jalviewjs_server_wait}"
- while(port < start+100 && !running) {
- try {
- server = factory.start(new File(jalviewDirAbsolutePath+"/"+jalviewjs_site_dir), port)
- running = true
- println("SERVER STARTED on "+server.getResourceUrl(jalviewjs_server_resource)+" for ${jalviewjs_server_wait} seconds. Ctrc+C to kill it.")
- java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000);
- } catch (Exception e) {
- port++;
+
+ if (jalviewjsServer != null) {
+ println("SERVER ALREADY RUNNING. Go to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle jalviewjsServerStop to stop.")
+ } else {
+
+ SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
+ def port = Integer.valueOf(jalviewjs_server_port)
+ def start = port
+ def running = false
+ while(port < start+1000 && !running) {
+ try {
+ jalviewjsServer = factory.start(new File(jalviewDirAbsolutePath+"/"+jalviewjs_site_dir), port)
+ running = true
+ println("SERVER STARTED. Go to "+jalviewjsServer.getResourceUrl(jalviewjs_server_resource)+" . Run gradle jalviewjsServerStop to stop.")
+ //println("Ctrl-c to stop.");java.lang.Thread.sleep(Integer.valueOf(jalviewjs_server_wait)*1000);
+ } catch (Exception e) {
+ port++;
+ }
}
+
}
+
}
+
}
+
+/* server persists in gradle daemon but reference is not accessible across builds
+task jalviewjsServerStop {
+ doLast {
+
+ if (jalviewjsServer != null) {
+
+ println("SERVER ON PORT "+jalviewjsServer.getPort()+" STOPPING. Run gradle jalviewjsServerStart to start again.")
+ jalviewjsServer.stop()
+
+ } else {
+ println("SERVER NOT RUNNING. Run gradle jalviewjsServerStart to start.")
+ }
+
+ }
+}
+*/