Skip to content

Commit

Permalink
tunnel server embedded redis support settgins. #1592
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyunabc committed Nov 26, 2020
1 parent 0aed289 commit 7b2b383
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.alibaba.arthas.tunnel.server.app.configuration;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -114,6 +117,7 @@ public static class EmbeddedRedis {
private boolean enabled = false;
private String host = "127.0.0.1";
private int port = 6379;
private List<String> settings = new ArrayList<String>();

public boolean isEnabled() {
return enabled;
Expand All @@ -138,6 +142,14 @@ public int getPort() {
public void setPort(int port) {
this.port = port;
}

public List<String> getSettings() {
return settings;
}

public void setSettings(List<String> settings) {
this.settings = settings;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.alibaba.arthas.tunnel.server.app.configuration.ArthasProperties.EmbeddedRedis;

import redis.embedded.RedisServer;
import redis.embedded.RedisServerBuilder;

/**
*
Expand All @@ -25,10 +26,13 @@ public class EmbeddedRedisConfiguration {
public RedisServer embeddedRedisServer(ArthasProperties arthasProperties) {
EmbeddedRedis embeddedRedis = arthasProperties.getEmbeddedRedis();

RedisServer redisServer = RedisServer.builder().port(embeddedRedis.getPort()).bind(embeddedRedis.getHost())
.build();
return redisServer;
RedisServerBuilder builder = RedisServer.builder().port(embeddedRedis.getPort()).bind(embeddedRedis.getHost());

for (String setting : embeddedRedis.getSettings()) {
builder.setting(setting);
}
RedisServer redisServer = builder.build();
return redisServer;
}

public static void main(String[] args) {
Expand Down
3 changes: 2 additions & 1 deletion tunnel-server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ spring.security.user.name=arthas

#arthas.enable-detatil-pages=true
#arthas.embedded-redis.enabled=true
#spring.redis.host=127.0.0.1
#arthas.embedded-redis.settings=maxmemory 128M
#spring.redis.host=127.0.0.1

0 comments on commit 7b2b383

Please sign in to comment.