Incorporate Clintons review comments

This commit is contained in:
Matthew Nesbit
2016-08-08 11:54:41 +01:00
parent 3dc8a95d69
commit 6b23800f02
3 changed files with 36 additions and 24 deletions

View File

@ -24,6 +24,8 @@ buildscript {
} }
plugins { plugins {
// TODO The capsule plugin requires the newer DSL plugin block.It would be nice if we could unify all the plugins into one style,
// but the DSL has some restrictions e.g can't be used on the allprojects section. So we should revisit this if there are improvements in Gradle.
id "us.kirchmeier.capsule" version "1.0.2" id "us.kirchmeier.capsule" version "1.0.2"
} }
@ -223,22 +225,15 @@ task createStandalone(dependsOn: 'createCapsule') << {
into "${buildDir}/standalone/nodeb" into "${buildDir}/standalone/nodeb"
rename 'generalnodeb.conf', 'node.conf' rename 'generalnodeb.conf', 'node.conf'
} }
delete("${buildDir}/standalone/runstandalone")
def myFile = file("${buildDir}/standalone/runstandalone") delete("${buildDir}/standalone/runstandalone")
def jarName = createCapsule.outputs.getFiles().getSingleFile().getName() def jarName = createCapsule.outputs.getFiles().getSingleFile().getName()
myFile << "#!/usr/bin/env bash\n" copy {
myFile << "set -euo pipefail\n" from "buildSrc/scripts/runstandalone"
myFile << "trap 'kill \$(jobs -p)' SIGINT SIGTERM EXIT\n" filter { String line -> line.replace("JAR_NAME",jarName) }
myFile << "export CAPSULE_CACHE_DIR=cache\n" filter(org.apache.tools.ant.filters.FixCrLfFilter.class, eol:org.apache.tools.ant.filters.FixCrLfFilter.CrLf.newInstance("lf"))
myFile << "pushd nameserver\n" into "${buildDir}/standalone"
myFile << "( java -jar "+ jarName+" )& \n" }
myFile << "popd\n"
myFile << "pushd nodea\n"
myFile << "( java -jar "+ jarName+" )& \n"
myFile << "popd\n"
myFile << "pushd nodeb\n"
myFile << "( java -jar "+ jarName+" )& \n"
myFile << "popd\n"
myFile << "read -p 'Any key to exit'\n"
myFile << "kill \$(jobs -p)\n"
} }

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
trap 'kill $(jobs -p)' SIGINT SIGTERM EXIT
export CAPSULE_CACHE_DIR=cache
pushd nameserver
( java -jar JAR_NAME )&
popd
pushd nodea
( java -jar JAR_NAME )&
popd
pushd nodeb
( java -jar JAR_NAME )&
popd
read -p 'Any key to exit'
kill $(jobs -p)

View File

@ -17,6 +17,8 @@ val log = LoggerFactory.getLogger("Main")
object ParamsSpec { object ParamsSpec {
val parser = OptionParser() val parser = OptionParser()
// The intent of allowing a command line configurable directory and config path is to allow deployment flexibility.
// Other general configuration should live inside the config file unless we regularly need temporary overrides on the command line
val baseDirectoryArg = val baseDirectoryArg =
parser.accepts("base-directory", "The directory to put all files under") parser.accepts("base-directory", "The directory to put all files under")
.withOptionalArg() .withOptionalArg()
@ -46,7 +48,7 @@ fun main(args: Array<String>) {
} }
val appConfig = ConfigFactory.parseFile(configFile) val appConfig = ConfigFactory.parseFile(configFile)
val cmdlineOverrideMap = HashMap<String, Any?>() val cmdlineOverrideMap = HashMap<String, Any?>() // If we do require a few other command line overrides eg for a nicer development experience they would go inside this map.
if (cmdlineOptions.has(ParamsSpec.baseDirectoryArg)) { if (cmdlineOptions.has(ParamsSpec.baseDirectoryArg)) {
cmdlineOverrideMap.put("basedir", baseDirectoryPath.toString()) cmdlineOverrideMap.put("basedir", baseDirectoryPath.toString())
} }
@ -59,12 +61,12 @@ fun main(args: Array<String>) {
val dir = conf.basedir.toAbsolutePath().normalize() val dir = conf.basedir.toAbsolutePath().normalize()
logInfo(args, dir) logInfo(args, dir)
val dirFile = dir.toFile()
if (!dirFile.exists()) {
dirFile.mkdirs()
}
try { try {
val dirFile = dir.toFile()
if (!dirFile.exists()) {
dirFile.mkdirs()
}
val node = conf.createNode() val node = conf.createNode()
node.start() node.start()
try { try {