Skip to content

Commit

Permalink
Added isActive method
Browse files Browse the repository at this point in the history
  • Loading branch information
kstyrc committed Oct 24, 2013
1 parent daa1898 commit b8df088
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ target
.project
.classpath
.settings
.idea
*.iml
9 changes: 6 additions & 3 deletions src/main/java/redis/embedded/RedisServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static String getRedisRunScript() {
private final File command;
private final Integer port;

private boolean active = false;
private volatile boolean active = false;
private Process redisProcess;

public RedisServer(File command, Integer port) {
Expand All @@ -73,16 +73,19 @@ private File extractExecutableFromJar(String scriptName) throws IOException {

return command;
}

public boolean isActive() {
return active;
}

public synchronized void start() throws IOException {
if (active) {
throw new RuntimeException("This redis server instance is already running...");
}

redisProcess = createRedisProcessBuilder().start();
active = true;

awaitRedisServerReady();
active = true;
}

private void awaitRedisServerReady() throws IOException {
Expand Down

0 comments on commit b8df088

Please sign in to comment.