From bedc850dea1d7d10f98f3c64a5c822f9ec46c060 Mon Sep 17 00:00:00 2001 From: Emil Gabrovski Date: Mon, 27 Mar 2023 10:36:36 +0300 Subject: [PATCH 1/2] CORE-12019 Add a Fast Check for already running CSDE before trying to start it --- .../src/main/java/com/r3/csde/CordaLifeCycleHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java b/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java index daa78a6..a61a56d 100644 --- a/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java +++ b/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java @@ -24,7 +24,11 @@ public class CordaLifeCycleHelper { } public void startCorda() throws IOException { - PrintStream pidStore = new PrintStream(new FileOutputStream(pc.cordaPidCache)); + File cordaPIDFile = new File(pc.cordaPidCache); + if (cordaPIDFile.exists()) { + throw new IOException("Cannot start the Combined worker\nCached process ID file " + cordaPIDFile + " existing.\nWas the combined worker already started?"); + } + PrintStream pidStore = new PrintStream(new FileOutputStream(cordaPIDFile)); File combinedWorkerJar = pc.project.getConfigurations().getByName("combinedWorker").getSingleFile(); // Manual version of the command to start postgres (for reference): From 67c888df2bf3b70c4566c75e54ed93f3f892cccf Mon Sep 17 00:00:00 2001 From: Emil Gabrovski Date: Tue, 28 Mar 2023 12:36:08 +0300 Subject: [PATCH 2/2] CORE-12019 Fix PR comments --- .../src/main/java/com/r3/csde/CordaLifeCycleHelper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java b/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java index a61a56d..c76382f 100644 --- a/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java +++ b/buildSrc/src/main/java/com/r3/csde/CordaLifeCycleHelper.java @@ -23,10 +23,10 @@ public class CordaLifeCycleHelper { Unirest.config().verifySsl(false); } - public void startCorda() throws IOException { + public void startCorda() throws IOException, CsdeException { File cordaPIDFile = new File(pc.cordaPidCache); if (cordaPIDFile.exists()) { - throw new IOException("Cannot start the Combined worker\nCached process ID file " + cordaPIDFile + " existing.\nWas the combined worker already started?"); + throw new CsdeException("Cannot start the Combined worker. Cached process ID file " + cordaPIDFile + " existing. Was the combined worker already started?"); } PrintStream pidStore = new PrintStream(new FileOutputStream(cordaPIDFile)); File combinedWorkerJar = pc.project.getConfigurations().getByName("combinedWorker").getSingleFile(); @@ -91,7 +91,7 @@ public class CordaLifeCycleHelper { cordaPIDFile.delete(); } else { - throw new CsdeException("Cannot stop the Combined worker\nCached process ID file " + pc.cordaPidCache + " missing.\nWas the combined worker not started?"); + throw new CsdeException("Cannot stop the Combined worker. Cached process ID file " + pc.cordaPidCache + " missing. Was the combined worker not started?"); } } }