Skip to content

Commit

Permalink
Terminate application after max events are reached
Browse files Browse the repository at this point in the history
Updated the README show the different arguments that are available
  • Loading branch information
DFieldFL committed Jan 28, 2021
1 parent 22b3529 commit a469d2b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ or
nohup java -agentlib:TakipiAgent -jar overops-event-generator-2.1.3.jar &
```

### Additional Command Line Arguments
| Argument | Description | Value Type | Default Value | Example |
|---|---|---|---|---|
| `oo.events` | Executes the number events specified and then terminates the application | Integer | -1 (run forever) | `--oo.events=100` |
| `server.port` | Specify http port to use | Integer | 8080 | `--server.port=1234`

## DB Console
You can view the H2 web console at `/console` for example `http://localhost:8080/console`. Use the following connection properties:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.takipi.sdk.v1.api.Takipi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;
Expand All @@ -25,6 +27,13 @@ public class OverOpsEventGeneratorApplication {

private static final int STARTUP_SLEEP = 10000;

private final ConfigurableApplicationContext context;

public OverOpsEventGeneratorApplication(
ConfigurableApplicationContext context) {
this.context = context;
}

public static void main(String[] args) {
SpringApplication.run(OverOpsEventGeneratorApplication.class, args);
}
Expand Down Expand Up @@ -120,6 +129,9 @@ public ApplicationRunner generateErrors(UserRepository repository, Controller co
}

log.info("event generator finished!!!! ran {} times and generated {} events.", invocationCounter.get(), eventCounter.get());

// Terminate the application since max number of events have been reached
System.exit(SpringApplication.exit(context));
};
}
}

0 comments on commit a469d2b

Please sign in to comment.