Correct CRLF for BAT files and fixed templating of JAR names.

This commit is contained in:
Clinton Alexander 2017-02-23 11:32:19 +00:00 committed by Clinton Alexander
parent 75ff04d5a7
commit f786ff9312
6 changed files with 26 additions and 15 deletions

View File

@ -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}/"
}
}
/**

View File

@ -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
}
}

View File

@ -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

View File

@ -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
)

View File

@ -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 {

View File

@ -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>(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)
}
}
}