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

Persistent random server id generation #5

Merged
merged 10 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<version>0.6.2</version>
<version>0.6.3</version>


<repositories>
<repository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,12 @@ private void loadConfig() throws IOException, JedisConnectionException {

// Configuration sanity checks.
if (serverId == null || serverId.isEmpty()) {
throw new RuntimeException("server-id is not specified in the configuration or is empty");
String genId = UUID.randomUUID().toString();
getLogger().info("Generated server id " + genId + " and saving it to config.");
configuration.set("server-id",genId);
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(getDataFolder(), "config.yml"));
} else {
getLogger().info("Loaded server id " + serverId + '.');
}

if (redisServer != null && !redisServer.isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/example_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ max-redis-connections: 8
useSSL: false


# An identifier for this BungeeCord instance.
server-id: test1
# An identifier for this BungeeCord instance. Will randomly generate if leaving it blank.
server-id: "test1"
# Should use random string? if enabled proxy id will be like this "test1-66cd2aeb-91f3-43a7-a106-e0307b098652"
# this great for servers who run replicas in Kubernetes or any auto deploying replica service
use-random-id-string: false
Expand Down