diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java index e1b87094..0425987a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java @@ -10,6 +10,9 @@ import ru.gravit.launchserver.command.hash.*; import ru.gravit.launchserver.command.modules.LoadModuleCommand; import ru.gravit.launchserver.command.modules.ModulesCommand; +import ru.gravit.launchserver.command.service.ReloadAllCommand; +import ru.gravit.launchserver.command.service.ReloadCommand; +import ru.gravit.launchserver.command.service.ReloadInfoCommand; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; @@ -108,6 +111,11 @@ protected CommandHandler(LaunchServer server) { //Register dump commands registerCommand("dumpSessions", new DumpSessionsCommand(server)); registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server)); + + //Register service commands + registerCommand("reload",new ReloadCommand(server)); + registerCommand("reloadAll",new ReloadAllCommand(server)); + registerCommand("reloadInfo",new ReloadInfoCommand(server)); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadAllCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadAllCommand.java new file mode 100644 index 00000000..6cce4298 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadAllCommand.java @@ -0,0 +1,28 @@ +package ru.gravit.launchserver.command.service; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; + +public class ReloadAllCommand extends Command { + public ReloadAllCommand(LaunchServer server) { + super(server); + } + + @Override + public String getArgsDescription() { + return ""; + } + + @Override + public String getUsageDescription() { + return "Reload all provider/handler/module config"; + } + + @Override + public void invoke(String... args) throws Exception { + verifyArgs(args,1); + LogHelper.info("Reload all config"); + server.reloadManager.reloadAll(); + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadCommand.java index ea7bf5b5..86673668 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadCommand.java @@ -2,6 +2,7 @@ import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; public class ReloadCommand extends Command { public ReloadCommand(LaunchServer server) { @@ -21,6 +22,7 @@ public String getUsageDescription() { @Override public void invoke(String... args) throws Exception { verifyArgs(args,1); - + LogHelper.info("Reload %s config",args[0]); + server.reloadManager.reload(args[0]); } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadInfoCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadInfoCommand.java new file mode 100644 index 00000000..ebfa04a1 --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ReloadInfoCommand.java @@ -0,0 +1,28 @@ +package ru.gravit.launchserver.command.service; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.LogHelper; + +public class ReloadInfoCommand extends Command { + public ReloadInfoCommand(LaunchServer server) { + super(server); + } + + @Override + public String getArgsDescription() { + return ""; + } + + @Override + public String getUsageDescription() { + return "print reloadable configs"; + } + + @Override + public void invoke(String... args) throws Exception { + verifyArgs(args,1); + LogHelper.info("Reload %s config",args[0]); + server.reloadManager.printReloadables(); + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java index 4ede4ee9..8f0b2305 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/manangers/ReloadManager.java @@ -28,4 +28,10 @@ public void reloadAll() public void reload(String name) throws Exception { RELOADABLES.get(name).reload(); } + public void printReloadables() + { + LogHelper.info("Print reloadables"); + RELOADABLES.forEach((k,v) -> LogHelper.subInfo(k)); + LogHelper.info("Found %d reloadables", RELOADABLES.size()); + } }