Skip to content

Commit

Permalink
Backward compatibility
Browse files Browse the repository at this point in the history
No need to register previous registered microservices:

* Initializing new attributes

* Regeneration init scripts

* Adding spring-boot-maven-plugin on microservices example
  • Loading branch information
ErnestOrt committed Aug 10, 2017
1 parent df4fa37 commit cf9e6c7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 10 deletions.
16 changes: 16 additions & 0 deletions microservice-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,20 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.ernest.applications.trampoline.exceptions;

public class CreatingMicroserviceScriptException extends Exception {
public class CreatingMicroserviceScriptException extends RuntimeException {

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package org.ernest.applications.trampoline.exceptions;

public class CreatingSettingsFolderException extends Exception{}
public class CreatingSettingsFolderException extends RuntimeException{}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.ernest.applications.trampoline.exceptions;

public class ReadingEcosystemException extends Exception {
public class ReadingEcosystemException extends RuntimeException {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.ernest.applications.trampoline.exceptions;

public class RunningMicroserviceScriptException extends Exception {
public class RunningMicroserviceScriptException extends RuntimeException {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.ernest.applications.trampoline.exceptions;

public class SavingEcosystemException extends Exception {
public class SavingEcosystemException extends RuntimeException {

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.ernest.applications.trampoline.exceptions;

public class ShuttingDownInstanceException extends Exception {
public class ShuttingDownInstanceException extends RuntimeException {

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,25 @@ public Ecosystem getEcosystem() throws CreatingSettingsFolderException, ReadingE
e.printStackTrace();
throw new ReadingEcosystemException();
}

updateMicroservicesInformationStored(ecosystem);

return ecosystem;
}


private void updateMicroservicesInformationStored(Ecosystem ecosystem) {
if(ecosystem.getMicroservices().stream().anyMatch(m -> m.getActuatorPrefix() == null || m.getVmArguments() == null)){

ecosystem.getMicroservices().stream().filter(m -> m.getActuatorPrefix() == null || m.getVmArguments() == null).forEach(m ->{
m.setVmArguments("");
m.setActuatorPrefix("");
createScript(m.getId(), m.getPomLocation());
});

saveEcosystem(ecosystem);
}
}

public void saveEcosystem(Ecosystem ecosystem) throws SavingEcosystemException {
try {
FileUtils.writeStringToFile(new File(getSettingsFolder() + "/" + settingsFileName), new Gson().toJson(ecosystem));
Expand All @@ -54,9 +70,8 @@ public void saveEcosystem(Ecosystem ecosystem) throws SavingEcosystemException {
}

public void runScript(String id, String mavenBinaryLocation, String mavenHomeLocation, String port, String vmArguments) throws RunningMicroserviceScriptException {
System.out.println(mavenBinaryLocation + " " + port);
try {
mavenBinaryLocation = (mavenBinaryLocation != null && mavenBinaryLocation.trim().length() > 0) ? mavenBinaryLocation: mavenHomeLocation + "/bin";
mavenBinaryLocation = (mavenBinaryLocation != null && mavenBinaryLocation.trim().length() > 0) ? mavenBinaryLocation : mavenHomeLocation + "/bin";
if(System.getProperties().getProperty("os.name").contains("Windows")){
String commands = FileUtils.readFileToString(new File(getSettingsFolder() +"/"+ id +".txt"));
commands = commands.replace("#mavenBinaryLocation", mavenBinaryLocation);
Expand All @@ -82,7 +97,7 @@ public void createScript(String id, String pomLocation) throws CreatingMicroserv
"SET M2_HOME=#mavenHomeLocation&& SET PATH=%PATH%;#mavenBinaryLocation&& cd " + pomLocation + " && mvn spring-boot:run -Dserver.port=#port "
+ "-Dendpoints.shutdown.enabled=true -Dmanagement.security.enabled=false #vmArguments");
}else{
FileUtils.writeStringToFile(new File(getSettingsFolder() +"/"+ id +".sh"),
FileUtils.writeStringToFile(new File(getSettingsFolder() +"/"+ id +".sh"),
"export M2_HOME=$1; export PATH=$PATH:$2; cd " + pomLocation + "; mvn spring-boot:run -Dserver.port=$3 "
+ "-Dendpoints.shutdown.enabled=true -Dmanagement.security.enabled=false $4");
}
Expand Down

0 comments on commit cf9e6c7

Please sign in to comment.