Reload,ReloadAll,ReloadInfo commands

This commit is contained in:
Gravit 2018-12-26 19:10:56 +07:00
parent 172eb97ce6
commit c7c270fc2c
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
5 changed files with 73 additions and 1 deletions

View file

@ -10,6 +10,9 @@
import ru.gravit.launchserver.command.hash.*; import ru.gravit.launchserver.command.hash.*;
import ru.gravit.launchserver.command.modules.LoadModuleCommand; import ru.gravit.launchserver.command.modules.LoadModuleCommand;
import ru.gravit.launchserver.command.modules.ModulesCommand; 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.LogHelper;
import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.utils.helper.VerifyHelper;
@ -108,6 +111,11 @@ protected CommandHandler(LaunchServer server) {
//Register dump commands //Register dump commands
registerCommand("dumpSessions", new DumpSessionsCommand(server)); registerCommand("dumpSessions", new DumpSessionsCommand(server));
registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server)); registerCommand("dumpEntryCache", new DumpEntryCacheCommand(server));
//Register service commands
registerCommand("reload",new ReloadCommand(server));
registerCommand("reloadAll",new ReloadAllCommand(server));
registerCommand("reloadInfo",new ReloadInfoCommand(server));
} }

View file

@ -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();
}
}

View file

@ -2,6 +2,7 @@
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
import ru.gravit.launchserver.command.Command; import ru.gravit.launchserver.command.Command;
import ru.gravit.utils.helper.LogHelper;
public class ReloadCommand extends Command { public class ReloadCommand extends Command {
public ReloadCommand(LaunchServer server) { public ReloadCommand(LaunchServer server) {
@ -21,6 +22,7 @@ public String getUsageDescription() {
@Override @Override
public void invoke(String... args) throws Exception { public void invoke(String... args) throws Exception {
verifyArgs(args,1); verifyArgs(args,1);
LogHelper.info("Reload %s config",args[0]);
server.reloadManager.reload(args[0]);
} }
} }

View file

@ -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();
}
}

View file

@ -28,4 +28,10 @@ public void reloadAll()
public void reload(String name) throws Exception { public void reload(String name) throws Exception {
RELOADABLES.get(name).reload(); 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());
}
} }