diff --git a/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Cordform.groovy b/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Cordform.groovy index 3cdbf8d69f..06a06887b0 100644 --- a/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Cordform.groovy +++ b/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Cordform.groovy @@ -67,13 +67,20 @@ class Cordform extends DefaultTask { protected void installRunScript() { project.copy { from Cordformation.getPluginFile(project, "net/corda/plugins/runnodes") - from Cordformation.getPluginFile(project, "net/corda/plugins/runnodes.bat") - filter { String line -> line.replace("JAR_NAME", Node.JAR_NAME) } + filter { String line -> line.replace("NODEJAR_NAME", Node.NODEJAR_NAME) } + filter { String line -> line.replace("WEBJAR_NAME", Node.WEBJAR_NAME) } // Replaces end of line with lf to avoid issues with the bash interpreter and Windows style line endings. filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf")) fileMode 0755 into "${directory}/" } + + project.copy { + from Cordformation.getPluginFile(project, "net/corda/plugins/runnodes.bat") + filter { String line -> line.replace("NODEJAR_NAME", Node.NODEJAR_NAME) } + filter { String line -> line.replace("WEBJAR_NAME", Node.WEBJAR_NAME) } + into "${directory}/" + } } /** diff --git a/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Node.groovy b/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Node.groovy index 8f36f2ae8a..a025325dab 100644 --- a/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Node.groovy +++ b/gradle-plugins/cordformation/src/main/groovy/net/corda/plugins/Node.groovy @@ -9,7 +9,7 @@ import java.nio.file.Files * Represents a node that will be installed. */ class Node { - static final String JAR_NAME = 'corda.jar' + static final String NODEJAR_NAME = 'corda.jar' static final String WEBJAR_NAME = 'corda-webserver.jar' static final String DEFAULT_HOST = 'localhost' @@ -110,7 +110,7 @@ class Node { /** * Set the network map address for this node. * - * @jarning This should not be directly set unless you know what you are doing. Use the networkMapName in the + * @warning This should not be directly set unless you know what you are doing. Use the networkMapName in the * Cordform task instead. * @param networkMapAddress Network map node address. * @param networkMapLegalName Network map node legal name. @@ -161,7 +161,7 @@ class Node { project.copy { from cordaJar into nodeDir - rename cordaJar.name, JAR_NAME + rename cordaJar.name, NODEJAR_NAME } } diff --git a/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes b/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes index dba2586fe9..d4b119cd8e 100755 --- a/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes +++ b/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes @@ -16,7 +16,7 @@ if which osascript >/dev/null; then rootdir=`pwd` for dir in `ls`; do if [ -d $dir ]; then - cmd="bash -c 'cd $rootdir/$dir; /usr/libexec/java_home -v 1.8 --exec java -jar JAR_NAME && exit'" + cmd="bash -c 'cd $rootdir/$dir; /usr/libexec/java_home -v 1.8 --exec java -jar NODEJAR_NAME && exit'" script="$script tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down delay 0.5 @@ -26,7 +26,7 @@ if which osascript >/dev/null; then done for dir in `ls`; do if [ -d $dir ]; then - cmd="bash -c 'cd $rootdir/$dir; /usr/libexec/java_home -v 1.8 --exec java -jar JAR_NAME --webserver && exit'" + cmd="bash -c 'cd $rootdir/$dir; /usr/libexec/java_home -v 1.8 --exec java -jar WEBJAR_NAME && exit'" script="$script tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down delay 0.5 @@ -48,8 +48,8 @@ else for dir in `ls`; do if [ -d $dir ]; then pushd $dir >/dev/null - xterm -T "`basename $dir`" -e 'java -jar JAR_NAME' & - xterm -T "`basename $dir` Web Server" -e 'java -jar JAR_NAME --webserver' & + xterm -T "`basename $dir`" -e 'java -jar NODEJAR_NAME' & + xterm -T "`basename $dir` Web Server" -e 'java -jar WEBJAR_NAME' & popd >/dev/null fi done diff --git a/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes.bat b/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes.bat index e2310ea434..0ef95a476d 100644 --- a/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes.bat +++ b/gradle-plugins/cordformation/src/main/resources/net/corda/plugins/runnodes.bat @@ -5,8 +5,8 @@ Pushd %~dp0 FOR /D %%G in (.\*) DO ( Pushd %%G - start java -jar corda.jar - start java -jar corda.jar --webserver + start java -jar NODEJAR_NAME + start java -jar WEBJAR_NAME Popd ) diff --git a/node/webserver/build.gradle b/node/webserver/build.gradle index 2e6da12390..96efca338a 100644 --- a/node/webserver/build.gradle +++ b/node/webserver/build.gradle @@ -3,6 +3,7 @@ apply plugin: 'java' apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'us.kirchmeier.capsule' +// TODO: Break dependency on node and move to another location such as a submodule of client. description 'Corda webserver module' repositories { diff --git a/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt b/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt index d5eb5d113e..a4ced3cb1b 100644 --- a/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt +++ b/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt @@ -92,17 +92,14 @@ class NodeWebServer(val config: FullNodeConfiguration) { val httpConfiguration = HttpConfiguration() httpConfiguration.outputBufferSize = 32768 val httpConnector = ServerConnector(server, HttpConnectionFactory(httpConfiguration)) - log.info("Starting webserver on address $address") httpConnector.port = address.port httpConnector } server.connectors = arrayOf(connector) server.handler = handlerCollection - //runOnStop += Runnable { server.stop() } server.start() - log.info("Server started") - log.info("Embedded web server is listening on", "http://${InetAddress.getLocalHost().hostAddress}:${connector.port}/") + log.info("Starting webserver on address $address") return server } @@ -158,6 +155,12 @@ class NodeWebServer(val config: FullNodeConfiguration) { } catch (e: ActiveMQNotConnectedException) { log.debug("Could not connect to ${config.artemisAddress} due to exception: ", e) Thread.sleep(retryDelay) + // This error will happen if the server has yet to create the keystore + // Keep the fully qualified package name due to collisions with the Kotlin stdlib + // exception of the same name + } catch (e: java.nio.file.NoSuchFileException) { + log.debug("Tried to open a file that doesn't yet exist, retrying", e) + Thread.sleep(retryDelay) } } }