Skip to content

Commit

Permalink
adding functionality for starting microservices in debug.
Browse files Browse the repository at this point in the history
  • Loading branch information
myrle-krantz committed Oct 6, 2018
1 parent 8b21607 commit 2b0ce09
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/main/java/org/apache/fineract/cn/dev/ServiceRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public class ServiceRunner {
private static DB embeddedMariaDb;

private static final String CUSTOM_PROP_PREFIX = "custom.";
private boolean runInDebug;

@Configuration
@ActiveMQForTest.EnableActiveMQListen
Expand Down Expand Up @@ -170,6 +171,7 @@ public void before() throws Exception
{
this.isPersistent = this.environment.containsProperty("demoserver.persistent");
this.shouldProvision = this.environment.containsProperty("demoserver.provision");
this.runInDebug = this.environment.containsProperty("demoserver.runInDebug");

if (!this.isPersistent) {
// start embedded Cassandra
Expand Down Expand Up @@ -275,17 +277,17 @@ public void startDevServer() throws InterruptedException, IOException, ArtifactR
ServiceRunner.provisionerService.kill();
}

System.out.println("Identity Service: " + ServiceRunner.identityManager.getProcessEnvironment().serverURI());
System.out.println("Office Service: " + ServiceRunner.organizationManager.getProcessEnvironment().serverURI());
System.out.println("Customer Service: " + ServiceRunner.customerManager.getProcessEnvironment().serverURI());
System.out.println("Accounting Service: " + ServiceRunner.ledgerManager.getProcessEnvironment().serverURI());
System.out.println("Portfolio Service: " + ServiceRunner.portfolioManager.getProcessEnvironment().serverURI());
System.out.println("Deposit Service: " + ServiceRunner.depositAccountManager.getProcessEnvironment().serverURI());
System.out.println("Teller Service: " + ServiceRunner.tellerManager.getProcessEnvironment().serverURI());
System.out.println("Reporting Service: " + ServiceRunner.reportManager.getProcessEnvironment().serverURI());
System.out.println("Cheque Service: " + ServiceRunner.chequeManager.getProcessEnvironment().serverURI());
System.out.println("Payroll Service: " + ServiceRunner.payrollManager.getProcessEnvironment().serverURI());
System.out.println("Group Service: " + ServiceRunner.groupManager.getProcessEnvironment().serverURI());
System.out.println(identityManager.toString());
System.out.println(organizationManager.toString());
System.out.println(customerManager.toString());
System.out.println(ledgerManager.toString());
System.out.println(portfolioManager.toString());
System.out.println(depositAccountManager.toString());
System.out.println(tellerManager.toString());
System.out.println(reportManager.toString());
System.out.println(chequeManager.toString());
System.out.println(payrollManager.toString());
System.out.println(groupManager.toString());

boolean run = true;

Expand All @@ -300,10 +302,16 @@ public void startDevServer() throws InterruptedException, IOException, ArtifactR
}

private void startService(ExtraProperties properties, Microservice microservice) throws InterruptedException, IOException, ArtifactResolutionException {
if (this.runInDebug) {
microservice.runInDebug();
}
microservice.addProperties(properties);
microservice.start();
final boolean registered = microservice.waitTillRegistered(discoveryClient);
logger.info("Service '{}' started and {} with Eureka.", microservice.name(), registered ? "registered" : "not registered");
if (this.runInDebug) {
logger.info("Service '{}' started with debug port {}.", microservice.name(), microservice.debuggingPort());
}
microservice.setApiFactory(this.apiFactory);

TimeUnit.SECONDS.sleep(20); //Give it some extra time before the next service...
Expand Down

0 comments on commit 2b0ce09

Please sign in to comment.