mirror of
https://github.com/corda/corda.git
synced 2025-02-05 02:29:20 +00:00
CORDA-1455 - Error in process-id deletion process allows multiple instances of same node to be run (fix). (#3118) (#3195)
This commit is contained in:
parent
2d1ceb6cb0
commit
f9e0742d69
@ -219,7 +219,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) {
|
||||
@ -227,6 +226,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…
x
Reference in New Issue
Block a user