Merge pull request #29 from corda/CORE-12019/Fast-Check-for-Already-Running-CSDE

CORE-12019 Add a Fast Check for already running CSDE before trying to start it
This commit is contained in:
egabrovski-r3 2023-03-28 17:26:38 +03:00 committed by GitHub
commit cd2e4bfc95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,8 +23,12 @@ public class CordaLifeCycleHelper {
Unirest.config().verifySsl(false); Unirest.config().verifySsl(false);
} }
public void startCorda() throws IOException { public void startCorda() throws IOException, CsdeException {
PrintStream pidStore = new PrintStream(new FileOutputStream(pc.cordaPidCache)); File cordaPIDFile = new File(pc.cordaPidCache);
if (cordaPIDFile.exists()) {
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(); File combinedWorkerJar = pc.project.getConfigurations().getByName("combinedWorker").getSingleFile();
// Manual version of the command to start postgres (for reference): // Manual version of the command to start postgres (for reference):
@ -87,7 +91,7 @@ public class CordaLifeCycleHelper {
cordaPIDFile.delete(); cordaPIDFile.delete();
} }
else { 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?");
} }
} }
} }