mirror of
https://github.com/DerDavidBohl/dirigent-spring.git
synced 2026-01-01 09:00:25 -06:00
Stop not configured Deployments
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
|
||||
POST http://localhost:8080/deployments/all/start
|
||||
POST http://localhost:8080/api/v1/deployments/all/start
|
||||
|
||||
@@ -40,6 +40,29 @@ public class DeploymentsService {
|
||||
DeploynentConfiguration deploymentsConfiguration = tryGetConfiguration();
|
||||
|
||||
deployAll(deploymentsConfiguration.deployments());
|
||||
|
||||
stopNotConfiguredDeployments(deploymentsConfiguration.deployments());
|
||||
}
|
||||
|
||||
private void stopNotConfiguredDeployments(List<Deployment> deployments) {
|
||||
File deploymentsDir = new File("deployments");
|
||||
File[] files = deploymentsDir.listFiles();
|
||||
|
||||
if(files == null)
|
||||
return;
|
||||
|
||||
for (File file : files) {
|
||||
if (file.isDirectory() && !deployments.stream().anyMatch(d -> d.name().equals(file.getName()))) {
|
||||
try {
|
||||
new ProcessBuilder(composeCommand, "down")
|
||||
.directory(file.getAbsoluteFile())
|
||||
.start()
|
||||
.waitFor();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deployAll(List<Deployment> deployments) {
|
||||
|
||||
Reference in New Issue
Block a user