Merged in mnesbit-cor-142-windows-fixes (pull request #97)

Mnesbit cor 142 windows fixes
This commit is contained in:
Matthew Nesbit 2016-05-16 15:16:58 +01:00
commit 56dea4d14e
2 changed files with 28 additions and 17 deletions

View File

@ -18,6 +18,7 @@ buildscript {
ext.artemis_version = '1.2.0'
ext.jetty_version = '9.1.1.v20140108'
ext.jersey_version = '2.22.2'
ext.jolokia_version = '2.0.0-M1'
repositories {
mavenCentral()
@ -89,7 +90,7 @@ dependencies {
compile "org.eclipse.jetty:jetty-servlet:${jetty_version}"
compile "org.eclipse.jetty:jetty-webapp:${jetty_version}"
compile "javax.servlet:javax.servlet-api:3.1.0"
compile "org.jolokia:jolokia-agent-war:2.0.0-M1"
compile "org.jolokia:jolokia-agent-war:${jolokia_version}"
compile "commons-fileupload:commons-fileupload:1.3.1"
// Jersey for JAX-RS implementation for use in Jetty
@ -157,6 +158,18 @@ task getIRSDemo(type: CreateStartScripts) {
classpath = jar.outputs.files + project.configurations.runtime
}
// Force windows script classpath to wildcard path to avoid the 'Command Line Is Too Long' issues
// with generated scripts. Include Jolokia .war explicitly as this isn't picked up by wildcard
tasks.withType(CreateStartScripts)
{
doLast {
windowsScript.text = windowsScript
.readLines()
.collect { line -> line.replaceAll(~/^set CLASSPATH=.*$/, 'set CLASSPATH=%APP_HOME%/lib/*;%APP_HOME%/lib/jolokia-agent-war-'+project.ext.jolokia_version+'.war') }
.join('\r\n')
}
}
// These lines tell gradle to run the Quasar suspendables scanner to look for unannotated super methods
// that have @Suspendable sub implementations. These tend to cause NPEs and are not caught by the verifier
// NOTE: need to make sure the output isn't on the classpath or every other run it generates empty results, so

View File

@ -23,9 +23,7 @@ import org.glassfish.jersey.servlet.ServletContainer
import java.io.RandomAccessFile
import java.lang.management.ManagementFactory
import java.nio.channels.FileLock
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardOpenOption
import java.time.Clock
import javax.management.ObjectName
@ -155,7 +153,10 @@ class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration
// twice with the same directory: that's a user error and we should bail out.
val pidPath = dir.resolve("process-id")
val file = pidPath.toFile()
if (file.exists()) {
if (!file.exists()) {
file.createNewFile()
}
file.deleteOnExit()
val f = RandomAccessFile(file, "rw")
val l = f.channel.tryLock()
if (l == null) {
@ -164,11 +165,8 @@ class Node(dir: Path, val p2pAddr: HostAndPort, configuration: NodeConfiguration
System.exit(1)
}
nodeFileLock = l
}
val ourProcessID: String = ManagementFactory.getRuntimeMXBean().name.split("@")[0]
Files.write(pidPath, ourProcessID.toByteArray(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)
pidPath.toFile().deleteOnExit()
if (nodeFileLock == null)
nodeFileLock = RandomAccessFile(file, "rw").channel.lock()
f.setLength(0)
f.write(ourProcessID.toByteArray())
}
}