mirror of
https://github.com/corda/corda.git
synced 2024-12-21 13:57:54 +00:00
[CORDA-1455]: Error in process-id deletion process allows multiple instances of same node to be run (fix). (#3118)
This commit is contained in:
parent
ecc0560ebc
commit
3a218b228d
@ -226,7 +226,6 @@ open class NodeStartup(val args: Array<String>) {
|
||||
// twice with the same directory: that's a user error and we should bail out.
|
||||
val pidFile = (baseDirectory / "process-id").toFile()
|
||||
pidFile.createNewFile()
|
||||
pidFile.deleteOnExit()
|
||||
val pidFileRw = RandomAccessFile(pidFile, "rw")
|
||||
val pidFileLock = pidFileRw.channel.tryLock()
|
||||
if (pidFileLock == null) {
|
||||
@ -234,6 +233,7 @@ open class NodeStartup(val args: Array<String>) {
|
||||
println("Shut that other node down and try again. It may have process ID ${pidFile.readText()}")
|
||||
System.exit(1)
|
||||
}
|
||||
pidFile.deleteOnExit()
|
||||
// Avoid the lock being garbage collected. We don't really need to release it as the OS will do so for us
|
||||
// when our process shuts down, but we try in stop() anyway just to be nice.
|
||||
addShutdownHook {
|
||||
|
Loading…
Reference in New Issue
Block a user