From 4c84b8c23c41f873f6f23c90772dbb29fd5fa2ba Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 5 Jul 2017 11:41:03 -0400 Subject: [PATCH] Adds an admin chat command to restart relays --- TGServerService/ChatCommands.cs | 20 +++++++++++++++++++- TGServerService/Interop.cs | 3 ++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/TGServerService/ChatCommands.cs b/TGServerService/ChatCommands.cs index 7ef47569b5..c560c4bd1b 100644 --- a/TGServerService/ChatCommands.cs +++ b/TGServerService/ChatCommands.cs @@ -41,7 +41,7 @@ namespace TGServerService public RootChatCommand() { PrintHelpList = true; - Children = new Command[] { new CheckCommand(), new StatusCommand(), new PRsCommand(), new VersionCommand(), new AHelpCommand(), new NameCheckCommand(), new RevisionCommand(), new AdminWhoCommand(), new ByondCommand(), new KekCommand() }; + Children = new Command[] { new CheckCommand(), new StatusCommand(), new PRsCommand(), new VersionCommand(), new AHelpCommand(), new NameCheckCommand(), new RevisionCommand(), new AdminWhoCommand(), new ByondCommand(), new KekCommand(), new RelayRestartCommand() }; } } class RevisionCommand : ChatCommand @@ -262,4 +262,22 @@ namespace TGServerService return " |list>>"; } } + class RelayRestartCommand : ChatCommand + { + public RelayRestartCommand() + { + Keyword = "relayrestart"; + RequiresAdmin = true; + } + protected override ExitCode Run(IList parameters) + { + Instance.InitInterop(); + return ExitCode.Normal; + } + + public override string GetHelpText() + { + return "Restart the relay listener. This is a massive hack but it'll do for now"; + } + } } diff --git a/TGServerService/Interop.cs b/TGServerService/Interop.cs index 7a62289d34..c0374bb74c 100644 --- a/TGServerService/Interop.cs +++ b/TGServerService/Interop.cs @@ -167,7 +167,7 @@ namespace TGServerService } //Start listening for nudges on the configured port - void InitInterop() + public void InitInterop() { lock (NudgeLock) { @@ -248,6 +248,7 @@ namespace TGServerService catch (Exception e) { TGServerService.WriteError("Nudge handler thread crashed: " + e.ToString(), TGServerService.EventID.NudgeCrash); + SendMessage("The relay handler crashed, use relayrestart to restore it! Error: " + e.Message, ChatMessageType.AdminInfo); } } }