Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis hangs when using Custom Provider with Redis 4.0.* #90

Open
AndyWilks79 opened this issue Nov 17, 2017 · 2 comments
Open

Redis hangs when using Custom Provider with Redis 4.0.* #90

AndyWilks79 opened this issue Nov 17, 2017 · 2 comments

Comments

@AndyWilks79
Copy link

When using a custom version of Redis, the code waits indefinitely for the Redis Server to start. This is because it is waiting for the following startup message as set on redis.embedded.RedisServer.class

REDIS_READY_PATTERN = ".The server is now ready to accept connections on port."

It appears as of version 4.0.* that the final startup statement issued by Redis is now - * Ready to accept connections.

As REDIS_READY_PATTERN is a final string and the method is protected access, it doesn't appear you can set the value when creating the server.

  @PostConstruct
  public void startRedis() throws Exception {
 
        RedisExecProvider customProvider = RedisExecProvider.defaultProvider()
        		  .override(OS.UNIX, "/path/to/unix/redis")
        		  .override(OS.WINDOWS, Architecture.x86, "/path/to/win/redis")
        		  .override(OS.WINDOWS, Architecture.x86_64, "/path/to/win/redis")
        		  .override(OS.MAC_OS_X, Architecture.x86, "/path/to/macosx/redis")
        		  .override(OS.MAC_OS_X, Architecture.x86_64, "/path/to/macosx/redis");
        		  
        this.redisServer = RedisServer.builder()
                .port(port)
                .setting("maxmemory 128M")
                .setting("daemonize no")    
                .setting("appendonly no")
                .redisExecProvider(customProvider)
                .build();
        		this.redisServer.start();
        		System.out.println(this.redisServer.isActive());
  }
@AndyWilks79
Copy link
Author

The way I discovered this was by adding println statements to AbstractRedisInstance.class to show the response received when starting Redis.

private void awaitRedisServerReady() throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(redisProcess.getInputStream()));
    try {
        String outputLine;
        do {
            outputLine = reader.readLine();
            if (outputLine == null) {
                //Something goes wrong. Stream is ended before server was activated.
                throw new RuntimeException("Can't start redis server. Check logs for details.");
            }
            System.out.println(outputLine);
            System.out.println(redisReadyPattern());
        } while (!outputLine.matches(redisReadyPattern()));
    } finally {
        IOUtils.closeQuietly(reader);
    }
}

@LaughXP
Copy link

LaughXP commented May 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants