mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 21:46:52 +01:00
Remove nudge port stuff
This commit is contained in:
Generated
+1902
-1946
File diff suppressed because it is too large
Load Diff
@@ -102,7 +102,6 @@ namespace TGControlPanel
|
||||
var RepoExists = Server.GetComponent<ITGRepository>().Exists();
|
||||
compileButton.Visible = RepoExists;
|
||||
initializeButton.Visible = RepoExists;
|
||||
NudgePortSelector.Visible = RepoExists;
|
||||
AutostartCheckbox.Visible = RepoExists;
|
||||
WebclientCheckBox.Visible = RepoExists;
|
||||
PortSelector.Visible = RepoExists;
|
||||
@@ -110,7 +109,6 @@ namespace TGControlPanel
|
||||
compilerProgressBar.Visible = RepoExists;
|
||||
CompilerStatusLabel.Visible = RepoExists;
|
||||
CompileCancelButton.Visible = RepoExists;
|
||||
NudgePortLabel.Visible = RepoExists;
|
||||
CompilerLabel.Visible = RepoExists;
|
||||
ProjectPathLabel.Visible = RepoExists;
|
||||
ServerPRLabel.Visible = RepoExists;
|
||||
@@ -163,20 +161,7 @@ namespace TGControlPanel
|
||||
PortSelector.Value = DD.Port();
|
||||
if (!projectNameText.Focused)
|
||||
projectNameText.Text = DM.ProjectName();
|
||||
|
||||
var val = Config.InteropPort(out string error);
|
||||
if (error != null)
|
||||
{
|
||||
updatingFields = false;
|
||||
NudgePortSelector.Value = 4567;
|
||||
MessageBox.Show("Error (I will try and recover): " + error);
|
||||
}
|
||||
else
|
||||
{
|
||||
updatingFields = false;
|
||||
NudgePortSelector.Value = val;
|
||||
}
|
||||
|
||||
|
||||
switch (DM.GetStatus())
|
||||
{
|
||||
case TGCompilerStatus.Compiling:
|
||||
@@ -215,7 +200,7 @@ namespace TGControlPanel
|
||||
CompileCancelButton.Enabled = true;
|
||||
break;
|
||||
}
|
||||
error = DM.CompileError();
|
||||
var error = DM.CompileError();
|
||||
if (error != null)
|
||||
MessageBox.Show("Error: " + error);
|
||||
}
|
||||
@@ -461,12 +446,6 @@ namespace TGControlPanel
|
||||
RunServerUpdate(FullUpdateAction.Testmerge, (ushort)ServerTestmergeInput.Value);
|
||||
}
|
||||
|
||||
private void NudgePortSelector_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!updatingFields)
|
||||
Server.GetComponent<ITGConfig>().SetInteropPort((ushort)NudgePortSelector.Value);
|
||||
}
|
||||
|
||||
private void SecuritySelector_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!updatingFields)
|
||||
|
||||
@@ -675,24 +675,6 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
//public api
|
||||
public string SetInteropPort(ushort port)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (configLock)
|
||||
{
|
||||
File.WriteAllText(InteropConfig, port.ToString());
|
||||
}
|
||||
InitInterop();
|
||||
return null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public IList<MapSetting> MapSettings(out string error)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -50,8 +50,6 @@ namespace TGServerService
|
||||
SendMessage("DD: Update complete. Watch dog reactivated...", ChatMessageType.WatchdogInfo);
|
||||
|
||||
//start wd
|
||||
InitInterop();
|
||||
|
||||
RestartInProgress = true;
|
||||
currentPort = Properties.Settings.Default.ReattachPort;
|
||||
serviceCommsKey = Properties.Settings.Default.ReattachCommsKey;
|
||||
@@ -236,7 +234,6 @@ namespace TGServerService
|
||||
currentStatus = TGDreamDaemonStatus.HardRebooting;
|
||||
currentPort = 0;
|
||||
Proc.Close();
|
||||
ShutdownInterop();
|
||||
|
||||
if (AwaitingShutdown == ShutdownRequestPhase.Pinged)
|
||||
return;
|
||||
@@ -280,7 +277,6 @@ namespace TGServerService
|
||||
RestartInProgress = true;
|
||||
}
|
||||
Proc.Close();
|
||||
ShutdownInterop();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@@ -394,7 +390,6 @@ namespace TGServerService
|
||||
StartingSecurity = (TGDreamDaemonSecurity)Config.ServerSecurity;
|
||||
Proc.StartInfo.Arguments = String.Format("{0} -port {1} {5}-close -verbose -params \"server_service={3}&server_service_version={4}\" -{2} -public", DMB, Config.ServerPort, SecurityWord(), serviceCommsKey, Version(), Config.Webclient ? "-webclient" : "");
|
||||
UpdateInterfaceDll(true);
|
||||
InitInterop();
|
||||
Proc.Start();
|
||||
|
||||
if (!Proc.WaitForInputIdle(DDHangStartTime * 1000))
|
||||
@@ -402,7 +397,6 @@ namespace TGServerService
|
||||
Proc.Kill();
|
||||
Proc.WaitForExit();
|
||||
Proc.Close();
|
||||
ShutdownInterop();
|
||||
currentStatus = TGDreamDaemonStatus.Offline;
|
||||
currentPort = 0;
|
||||
return String.Format("Server start is taking more than {0}s! Aborting!", DDHangStartTime);
|
||||
|
||||
@@ -17,9 +17,6 @@ namespace TGServerService
|
||||
const int CommsKeyLen = 64;
|
||||
string serviceCommsKey; //regenerated every DD restart
|
||||
|
||||
Thread NudgeThread;
|
||||
object NudgeLock = new object();
|
||||
|
||||
//See code/modules/server_tools/server_tools.dm for command switch
|
||||
const string SCHardReboot = "hard_reboot"; //requests that dreamdaemon restarts when the round ends
|
||||
const string SCGracefulShutdown = "graceful_shutdown"; //requests that dreamdaemon stops when the round ends
|
||||
@@ -171,93 +168,6 @@ namespace TGServerService
|
||||
TGServerService.WriteInfo("Service Comms Key set to: " + serviceCommsKey, TGServerService.EventID.CommsKeySet);
|
||||
}
|
||||
|
||||
//Start listening for nudges on the configured port
|
||||
public void InitInterop()
|
||||
{
|
||||
lock (NudgeLock)
|
||||
{
|
||||
ShutdownInteropNoLock();
|
||||
NudgeThread = new Thread(new ThreadStart(NudgeHandler)) { IsBackground = true };
|
||||
NudgeThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
void ShutdownInterop()
|
||||
{
|
||||
lock (NudgeLock)
|
||||
{
|
||||
ShutdownInteropNoLock();
|
||||
}
|
||||
}
|
||||
|
||||
void ShutdownInteropNoLock()
|
||||
{
|
||||
if (NudgeThread != null)
|
||||
{
|
||||
NudgeThread.Abort();
|
||||
NudgeThread.Join();
|
||||
}
|
||||
}
|
||||
|
||||
void NudgeHandler()
|
||||
{
|
||||
try
|
||||
{
|
||||
var np = InteropPort(out string error);
|
||||
if (error != null)
|
||||
{
|
||||
TGServerService.WriteError("Unable to start nudge handler: " + error, TGServerService.EventID.NudgeStartFail);
|
||||
return;
|
||||
}
|
||||
|
||||
using (var listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
listener.Bind(new IPEndPoint(IPAddress.Any, np));
|
||||
listener.Listen(5);
|
||||
|
||||
// Start listening for connections.
|
||||
using (var clientConnected = new ManualResetEvent(false))
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// Program is suspended while waiting for an incoming connection.
|
||||
clientConnected.Reset();
|
||||
listener.BeginAccept(delegate (IAsyncResult asyncResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var handler = listener.EndAccept(asyncResult))
|
||||
{
|
||||
|
||||
var bytes = new byte[1024];
|
||||
int bytesRec = handler.Receive(bytes);
|
||||
// Show the data on the console.
|
||||
HandleCommand(Encoding.ASCII.GetString(bytes, 0, bytesRec));
|
||||
|
||||
handler.Close();
|
||||
clientConnected.Set();
|
||||
}
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{ }
|
||||
}, null);
|
||||
clientConnected.WaitOne();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
TGServerService.WriteError("Nudge handler thread crashed: " + e.ToString(), TGServerService.EventID.NudgeCrash);
|
||||
SendMessage("SERVICE: The relay handler crashed, I will attempt to restore it when the server reboots! Error: " + e.Message, ChatMessageType.AdminInfo);
|
||||
RequestRestart();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool InteropMessage(string command)
|
||||
{
|
||||
|
||||
@@ -273,22 +273,6 @@ namespace TGServiceInterface
|
||||
[OperationContract]
|
||||
string SetMapSettings(MapSetting newSetting);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the port DD uses to talk to the service
|
||||
/// </summary>
|
||||
/// <param name="error">null on success, error message on failure</param>
|
||||
/// <returns>The port DD uses to talk to the service or 0 on failure</returns>
|
||||
[OperationContract]
|
||||
ushort InteropPort(out string error);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the port DD uses to talk to the service
|
||||
/// </summary>
|
||||
/// <param name="port">The port DD uses to talk to the service</param>
|
||||
/// <returns>null on success, error message on failure</returns>
|
||||
[OperationContract]
|
||||
string SetInteropPort(ushort port);
|
||||
|
||||
/// <summary>
|
||||
/// Return the directory of the server on the host machine
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user