mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Added better status detection for stopping servers
This commit is contained in:
parent
034a6228d7
commit
3c822fa982
14 changed files with 183 additions and 46 deletions
|
|
@ -257,6 +257,8 @@ namespace ServerManagerTool.Lib
|
|||
return;
|
||||
}
|
||||
|
||||
ServerStatusChangeCallback?.Invoke(ServerStatus.Stopped);
|
||||
|
||||
// make a backup of the current profile and config files.
|
||||
CreateProfileBackupArchiveFile(_profile);
|
||||
|
||||
|
|
@ -404,6 +406,7 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
|
||||
_serverRunning = true;
|
||||
ServerStatusChangeCallback?.Invoke(ServerStatus.Stopping);
|
||||
LogProfileMessage($"Server process found PID {process.Id}.");
|
||||
|
||||
QueryMaster.Server gameServer = null;
|
||||
|
|
@ -1165,6 +1168,8 @@ namespace ServerManagerTool.Lib
|
|||
if (ExitCode != EXITCODE_NORMALEXIT)
|
||||
return;
|
||||
|
||||
ServerStatusChangeCallback?.Invoke(ServerStatus.Stopped);
|
||||
|
||||
emailMessage.AppendLine("Update Summary:");
|
||||
emailMessage.AppendLine();
|
||||
emailMessage.AppendLine($"Server Manager version: {App.Instance.Version}");
|
||||
|
|
@ -2435,7 +2440,7 @@ namespace ServerManagerTool.Lib
|
|||
_loggerBranch?.Info(message);
|
||||
|
||||
if (includeProgressCallback)
|
||||
ProgressCallback?.Invoke(0, $"[INFO] {message}");
|
||||
ProgressCallback?.Invoke(0, $"{message}");
|
||||
|
||||
Debug.WriteLine($"[INFO] (Branch {GetBranchName(branchName) ?? "unknown"}) {message}");
|
||||
}
|
||||
|
|
@ -2460,7 +2465,7 @@ namespace ServerManagerTool.Lib
|
|||
_loggerProfile?.Info(message);
|
||||
|
||||
if (includeProgressCallback)
|
||||
ProgressCallback?.Invoke(0, $"[INFO] {message}");
|
||||
ProgressCallback?.Invoke(0, $"{message}");
|
||||
|
||||
Debug.WriteLine($"[INFO] (Profile {_profile?.ProfileName ?? "unknown"}) {message}");
|
||||
}
|
||||
|
|
@ -2709,6 +2714,8 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
}
|
||||
|
||||
ServerStatusChangeCallback?.Invoke(ServerStatus.Unknown);
|
||||
|
||||
LogProfileMessage("");
|
||||
LogProfileMessage($"Exitcode = {ExitCode}");
|
||||
return ExitCode;
|
||||
|
|
@ -2806,6 +2813,8 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
}
|
||||
|
||||
ServerStatusChangeCallback?.Invoke(ServerStatus.Unknown);
|
||||
|
||||
LogProfileMessage("");
|
||||
LogProfileMessage($"Exitcode = {ExitCode}");
|
||||
return ExitCode;
|
||||
|
|
@ -2886,6 +2895,8 @@ namespace ServerManagerTool.Lib
|
|||
}
|
||||
}
|
||||
|
||||
ServerStatusChangeCallback?.Invoke(ServerStatus.Unknown);
|
||||
|
||||
LogProfileMessage("");
|
||||
LogProfileMessage($"Exitcode = {ExitCode}");
|
||||
return ExitCode;
|
||||
|
|
|
|||
|
|
@ -274,20 +274,32 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
case WatcherServerStatus.RunningLocalCheck:
|
||||
if (oldStatus != ServerStatus.Stopping)
|
||||
{
|
||||
UpdateServerStatus(ServerStatus.Running, this.Availability != AvailabilityStatus.Available ? AvailabilityStatus.Waiting : this.Availability, oldStatus != ServerStatus.Running && oldStatus != ServerStatus.Unknown);
|
||||
if (this.ProfileSnapshot.MOTDIntervalEnabled && this.motdIntervalTimer != null && !this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Start();
|
||||
if (this.ProfileSnapshot.MOTDIntervalEnabled && this.motdIntervalTimer != null && !this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Start();
|
||||
}
|
||||
else
|
||||
if (this.motdIntervalTimer != null && this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Stop();
|
||||
break;
|
||||
|
||||
case WatcherServerStatus.RunningExternalCheck:
|
||||
if (oldStatus != ServerStatus.Stopping)
|
||||
{
|
||||
UpdateServerStatus(ServerStatus.Running, AvailabilityStatus.Waiting, oldStatus != ServerStatus.Running && oldStatus != ServerStatus.Unknown);
|
||||
if (this.ProfileSnapshot.MOTDIntervalEnabled && this.motdIntervalTimer != null && !this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Start();
|
||||
if (this.ProfileSnapshot.MOTDIntervalEnabled && this.motdIntervalTimer != null && !this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Start();
|
||||
}
|
||||
else
|
||||
if (this.motdIntervalTimer != null && this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Stop();
|
||||
break;
|
||||
|
||||
case WatcherServerStatus.Published:
|
||||
if (oldStatus != ServerStatus.Stopping)
|
||||
{
|
||||
UpdateServerStatus(ServerStatus.Running, AvailabilityStatus.Available, oldStatus != ServerStatus.Running && oldStatus != ServerStatus.Unknown);
|
||||
if (this.ProfileSnapshot.MOTDIntervalEnabled && this.motdIntervalTimer != null && !this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Start();
|
||||
if (this.ProfileSnapshot.MOTDIntervalEnabled && this.motdIntervalTimer != null && !this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Start();
|
||||
}
|
||||
else
|
||||
if (this.motdIntervalTimer != null && this.motdIntervalTimer.Enabled) this.motdIntervalTimer.Stop();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -965,7 +977,23 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
public void UpdateServerStatus(ServerStatus serverStatus, bool sendAlert)
|
||||
{
|
||||
UpdateServerStatus(serverStatus, Availability, sendAlert);
|
||||
var availability = Availability;
|
||||
|
||||
switch (serverStatus)
|
||||
{
|
||||
case ServerStatus.Stopped:
|
||||
case ServerStatus.Stopping:
|
||||
case ServerStatus.Uninstalled:
|
||||
case ServerStatus.Updating:
|
||||
availability = AvailabilityStatus.Unavailable;
|
||||
break;
|
||||
case ServerStatus.Unknown:
|
||||
availability = AvailabilityStatus.Unknown;
|
||||
sendAlert = false;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateServerStatus(serverStatus, availability, sendAlert);
|
||||
}
|
||||
|
||||
public void UpdateServerStatus(ServerStatus serverStatus, AvailabilityStatus availabilityStatus, bool sendAlert)
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ namespace ServerManagerTool.Utils
|
|||
var server = ServerManager.Instance.Servers.First(s => string.Equals(channelId, s.Profile.DiscordChannelId, StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(profileIdOrAlias, s.Profile.ProfileID, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.IsNullOrWhiteSpace(s.Profile.DiscordAlias) && string.Equals(profileIdOrAlias, s.Profile.DiscordAlias, StringComparison.OrdinalIgnoreCase)));
|
||||
server.Runtime.UpdateServerStatus(serverStatus, true);
|
||||
server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
|
||||
}).Wait();
|
||||
}
|
||||
};
|
||||
|
|
@ -408,7 +408,7 @@ namespace ServerManagerTool.Utils
|
|||
var server = ServerManager.Instance.Servers.First(s => string.Equals(channelId, s.Profile.DiscordChannelId, StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(profileIdOrAlias, s.Profile.ProfileID, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.IsNullOrWhiteSpace(s.Profile.DiscordAlias) && string.Equals(profileIdOrAlias, s.Profile.DiscordAlias, StringComparison.OrdinalIgnoreCase)));
|
||||
server.Runtime.UpdateServerStatus(serverStatus, true);
|
||||
server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
|
||||
}).Wait();
|
||||
}
|
||||
};
|
||||
|
|
@ -509,7 +509,7 @@ namespace ServerManagerTool.Utils
|
|||
var server = ServerManager.Instance.Servers.First(s => string.Equals(channelId, s.Profile.DiscordChannelId, StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(profileIdOrAlias, s.Profile.ProfileID, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.IsNullOrWhiteSpace(s.Profile.DiscordAlias) && string.Equals(profileIdOrAlias, s.Profile.DiscordAlias, StringComparison.OrdinalIgnoreCase)));
|
||||
server.Runtime.UpdateServerStatus(serverStatus, true);
|
||||
server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
|
||||
}).Wait();
|
||||
}
|
||||
};
|
||||
|
|
@ -611,7 +611,7 @@ namespace ServerManagerTool.Utils
|
|||
var server = ServerManager.Instance.Servers.First(s => string.Equals(channelId, s.Profile.DiscordChannelId, StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(profileIdOrAlias, s.Profile.ProfileID, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.IsNullOrWhiteSpace(s.Profile.DiscordAlias) && string.Equals(profileIdOrAlias, s.Profile.DiscordAlias, StringComparison.OrdinalIgnoreCase)));
|
||||
server.Runtime.UpdateServerStatus(serverStatus, true);
|
||||
server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
|
||||
}).Wait();
|
||||
}
|
||||
};
|
||||
|
|
@ -713,7 +713,7 @@ namespace ServerManagerTool.Utils
|
|||
var server = ServerManager.Instance.Servers.First(s => string.Equals(channelId, s.Profile.DiscordChannelId, StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(profileIdOrAlias, s.Profile.ProfileID, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.IsNullOrWhiteSpace(s.Profile.DiscordAlias) && string.Equals(profileIdOrAlias, s.Profile.DiscordAlias, StringComparison.OrdinalIgnoreCase)));
|
||||
server.Runtime.UpdateServerStatus(serverStatus, true);
|
||||
server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
|
||||
}).Wait();
|
||||
}
|
||||
};
|
||||
|
|
@ -817,7 +817,7 @@ namespace ServerManagerTool.Utils
|
|||
var server = ServerManager.Instance.Servers.First(s => string.Equals(channelId, s.Profile.DiscordChannelId, StringComparison.OrdinalIgnoreCase)
|
||||
&& (string.Equals(profileIdOrAlias, s.Profile.ProfileID, StringComparison.OrdinalIgnoreCase)
|
||||
|| !string.IsNullOrWhiteSpace(s.Profile.DiscordAlias) && string.Equals(profileIdOrAlias, s.Profile.DiscordAlias, StringComparison.OrdinalIgnoreCase)));
|
||||
server.Runtime.UpdateServerStatus(serverStatus, true);
|
||||
server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
|
||||
}).Wait();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
<entry>
|
||||
<id>urn:uuid:19B09A66-43F2-4D5F-AF33-5C77D7EA9A6B</id>
|
||||
<title>1.1.58 (1.1.58.16)</title>
|
||||
<summary>1.1.58.16</summary>
|
||||
<title>1.1.58 (1.1.58.17)</title>
|
||||
<summary>1.1.58.17</summary>
|
||||
<link href="" />
|
||||
<updated>2021-12-20T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
|
|
|
|||
|
|
@ -7,6 +7,29 @@
|
|||
<link href="http://servermanagers.freeforums.net/" />
|
||||
<updated>2021-12-20T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:25F39F6F-E7FE-417D-9BC9-EC6EF7DEC1BC</id>
|
||||
<title>1.1.58 (1.1.58.17)</title>
|
||||
<summary>1.1.58.17</summary>
|
||||
<link href="" />
|
||||
<updated>2021-12-20T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||
<p>
|
||||
<u style="font-size: .9em;">CHANGE</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<li>Added better status detection for stopping servers.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>bletch</name>
|
||||
<email>bletch1971@hotmail.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:0C184A8F-803D-4AC6-B9CB-599810F9AD29</id>
|
||||
<title>1.1.58 (1.1.58.16)</title>
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@
|
|||
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopping}">
|
||||
<Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusOn.ico,Size=32}"/>
|
||||
<Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusStarting.ico,Size=32}"/>
|
||||
<Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppingLabel}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}">
|
||||
|
|
|
|||
|
|
@ -1,17 +1,16 @@
|
|||
using ServerManagerTool.Common;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Enums;
|
||||
using ServerManagerTool.Lib;
|
||||
using ServerManagerTool.Plugin.Common;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using ServerManagerTool.Common;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using ServerManagerTool.Enums;
|
||||
using ServerManagerTool.Lib;
|
||||
using ServerManagerTool.Plugin.Common;
|
||||
using WPFSharp.Globalizer;
|
||||
using static ServerManagerTool.Lib.ServerApp;
|
||||
|
||||
namespace ServerManagerTool
|
||||
{
|
||||
|
|
@ -228,6 +227,13 @@ namespace ServerManagerTool
|
|||
SendAlerts = true,
|
||||
ServerProcess = RestartServer ? ServerProcessType.Restart : ServerProcessType.Shutdown,
|
||||
ProgressCallback = (p, m, n) => { TaskUtils.RunOnUIThreadAsync(() => { this.AddMessage(m, n); }).DoNotWait(); },
|
||||
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
|
||||
{
|
||||
TaskUtils.RunOnUIThreadAsync(() =>
|
||||
{
|
||||
Server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
|
||||
}).Wait();
|
||||
}
|
||||
};
|
||||
|
||||
// if restarting the serverm, then check and update the public IP address
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue