diff --git a/src/ARKServerManager/Globalization/en-US/en-US.xaml b/src/ARKServerManager/Globalization/en-US/en-US.xaml
index c2a65f54..597c4289 100644
--- a/src/ARKServerManager/Globalization/en-US/en-US.xaml
+++ b/src/ARKServerManager/Globalization/en-US/en-US.xaml
@@ -451,6 +451,9 @@
Create a desktop shortcut to open this form directly.
Start the selected servers.
+ Shutdown Selected Servers
+ Shutdown the selected servers.
+ Stop Selected Servers
Stop the selected servers.
Restart the selected servers.
Update the selected servers.
@@ -468,6 +471,8 @@
Another server is being upgraded, wait until the upgrade has finished and try again.
Confirm Window Close
You are currently performing a server update, closing the window will disconnect you from steamcmd. Do you want to continue closing the window?
+ Confirm Shutdown Servers
+ You are about to shutdown the selected servers. Do you want to continue?
Confirm Start Servers
You are about to start the selected servers. Do you want to continue?
Confirm Stop Servers
diff --git a/src/ARKServerManager/Lib/ServerApp.cs b/src/ARKServerManager/Lib/ServerApp.cs
index 24790303..7f8af24f 100644
--- a/src/ARKServerManager/Lib/ServerApp.cs
+++ b/src/ARKServerManager/Lib/ServerApp.cs
@@ -102,6 +102,7 @@ namespace ServerManagerTool.Lib
public bool DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles;
public int ExitCode = EXITCODE_NORMALEXIT;
public bool OutputLogs = false;
+ public bool PerformWorldSave = Config.Default.ServerShutdown_EnableWorldSave;
public bool SendAlerts = false;
public bool SendEmails = false;
public string ShutdownReason = null;
@@ -258,11 +259,14 @@ namespace ServerManagerTool.Lib
ServerStatusChangeCallback?.Invoke(ServerStatus.Stopped);
- // make a backup of the current profile and config files.
- CreateProfileBackupArchiveFile(_profile);
+ if (ServerProcess != ServerProcessType.Stop)
+ {
+ // make a backup of the current profile and config files.
+ CreateProfileBackupArchiveFile(_profile);
- if (ExitCode != EXITCODE_NORMALEXIT)
- return;
+ if (ExitCode != EXITCODE_NORMALEXIT)
+ return;
+ }
if (BackupWorldFile)
{
@@ -285,10 +289,10 @@ namespace ServerManagerTool.Lib
{
ServerStatusChangeCallback?.Invoke(ServerStatus.Stopped);
}
- }
- if (ExitCode != EXITCODE_NORMALEXIT)
- return;
+ if (ExitCode != EXITCODE_NORMALEXIT)
+ return;
+ }
// check if this is a shutdown only, or a shutdown and restart.
if (restartServer)
@@ -580,7 +584,7 @@ namespace ServerManagerTool.Lib
}
// check if we need to perform a world save (not required for SotF servers)
- if (serverAccessible && Config.Default.ServerShutdown_EnableWorldSave && !_profile.SotFEnabled)
+ if (serverAccessible && PerformWorldSave && !_profile.SotFEnabled)
{
try
{
@@ -671,35 +675,38 @@ namespace ServerManagerTool.Lib
process.Exited += handler;
// Method 1 - Shutdown Command
- if (serverAccessible && _profile.RCONEnabled && Config.Default.ServerShutdown_UseShutdownCommand)
+ if (ServerProcess != ServerProcessType.Stop)
{
- try
+ if (serverAccessible && _profile.RCONEnabled && Config.Default.ServerShutdown_UseShutdownCommand)
{
- sent = SendCommand(Config.Default.ServerShutdownCommand, cancellationToken);
- if (sent)
+ try
{
- Task.Delay(10000, cancellationToken).Wait(cancellationToken);
+ sent = SendCommand(Config.Default.ServerShutdownCommand, cancellationToken);
+ if (sent)
+ {
+ Task.Delay(10000, cancellationToken).Wait(cancellationToken);
+ }
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine($"RCON> {Config.Default.ServerShutdownCommand} command.\r\n{ex.Message}");
}
- }
- catch (Exception ex)
- {
- Debug.WriteLine($"RCON> {Config.Default.ServerShutdownCommand} command.\r\n{ex.Message}");
- }
- if (sent && !process.HasExited)
- {
- ts.Task.Wait(60000); // 1 minute
- }
+ if (sent && !process.HasExited)
+ {
+ ts.Task.Wait(60000); // 1 minute
+ }
- if (process.HasExited)
- {
- LogProfileMessage($"Exited server successfully.");
- LogProfileMessage("");
- ExitCode = EXITCODE_NORMALEXIT;
- return;
- }
+ if (process.HasExited)
+ {
+ LogProfileMessage($"Exited server successfully.");
+ LogProfileMessage("");
+ ExitCode = EXITCODE_NORMALEXIT;
+ return;
+ }
- LogProfileMessage("Exiting server timed out, attempting to close the server.");
+ LogProfileMessage("Exiting server timed out, attempting to close the server.");
+ }
}
// Method 2 - Close the process
diff --git a/src/ARKServerManager/Utils/DiscordBotHelper.cs b/src/ARKServerManager/Utils/DiscordBotHelper.cs
index 1de7d20c..152c5de6 100644
--- a/src/ARKServerManager/Utils/DiscordBotHelper.cs
+++ b/src/ARKServerManager/Utils/DiscordBotHelper.cs
@@ -58,11 +58,11 @@ namespace ServerManagerTool.Utils
return new List { string.Format(_globalizer.GetResourceString("DiscordBot_CommandNotEnabled"), commandType) };
case CommandType.Shutdown:
if (Config.Default.AllowDiscordShutdown)
- return ShutdownServer(channelId, profileIdOrAlias, token);
+ return StopServer(channelId, profileIdOrAlias, true, token);
return new List { string.Format(_globalizer.GetResourceString("DiscordBot_CommandNotEnabled"), commandType) };
case CommandType.Stop:
if (Config.Default.AllowDiscordStop)
- return StopServer(channelId, profileIdOrAlias, token);
+ return StopServer(channelId, profileIdOrAlias, false, token);
return new List { string.Format(_globalizer.GetResourceString("DiscordBot_CommandNotEnabled"), commandType) };
case CommandType.Start:
if (Config.Default.AllowDiscordStart)
@@ -475,112 +475,7 @@ namespace ServerManagerTool.Utils
return responseList;
}
- private static IList ShutdownServer(string channelId, string profileIdOrAlias, CancellationToken token)
- {
- if (string.IsNullOrWhiteSpace(profileIdOrAlias))
- {
- return new List { string.Format(_globalizer.GetResourceString("DiscordBot_ProfileMissing"), CommandType.Shutdown) };
- }
-
- var profileList = new List();
- var responseList = new List();
-
- TaskUtils.RunOnUIThreadAsync(() =>
- {
- var serverList = ServerManager.Instance.Servers.Where(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)
- || !string.IsNullOrWhiteSpace(Config.Default.DiscordBotAllServersKeyword) && string.Equals(profileIdOrAlias, Config.Default.DiscordBotAllServersKeyword, StringComparison.OrdinalIgnoreCase)
- || s.Profile.AllowDiscordClusterAlias && string.Equals(profileIdOrAlias, s.Profile.CrossArkClusterId, StringComparison.OrdinalIgnoreCase)
- )
- );
-
- if (serverList.IsEmpty())
- {
- if (!string.IsNullOrWhiteSpace(Config.Default.DiscordBotAllServersKeyword) && string.Equals(profileIdOrAlias, Config.Default.DiscordBotAllServersKeyword, StringComparison.OrdinalIgnoreCase))
- {
- responseList.Add(_globalizer.GetResourceString("DiscordBot_NoChannelProfiles"));
- }
- else
- {
- responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_ProfileNotFound"), profileIdOrAlias));
- }
- }
- else
- {
- foreach (var server in serverList)
- {
- if (!server.Profile.AllowDiscordShutdown)
- {
- responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_CommandDisabledProfile"), CommandType.Shutdown, server.Profile.ProfileName));
- continue;
- }
-
- // check if another command is being run against the profile
- if (_currentProfileCommands.ContainsKey(server.Profile.ProfileID))
- {
- responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_CommandRunningProfile"), _currentProfileCommands[server.Profile.ProfileID], server.Profile.ProfileName));
- continue;
- }
-
- switch (server.Runtime.Status)
- {
- case ServerStatus.Initializing:
- case ServerStatus.Stopping:
- case ServerStatus.Stopped:
- case ServerStatus.Uninstalled:
- case ServerStatus.Unknown:
- responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_ProfileBadStatus"), server.Profile.ProfileName, server.Runtime.StatusString));
- continue;
-
- case ServerStatus.Updating:
- responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_ProfileUpdating"), server.Profile.ProfileName));
- continue;
- }
-
- _currentProfileCommands.Add(server.Profile.ProfileID, CommandType.Shutdown);
- profileList.Add(ServerProfileSnapshot.Create(server.Profile));
- }
- }
- }).Wait(token);
-
- foreach (var profile in profileList)
- {
- var app = new ServerApp(true)
- {
- DeleteOldBackupFiles = !Config.Default.AutoBackup_EnableBackup,
- OutputLogs = false,
- SendAlerts = true,
- SendEmails = false,
- ServerProcess = ServerProcessType.Shutdown,
- ServerStatusChangeCallback = (ServerStatus serverStatus) =>
- {
- TaskUtils.RunOnUIThreadAsync(() =>
- {
- var server = ServerManager.Instance.Servers.FirstOrDefault(s => string.Equals(profile.ProfileId, s.Profile.ProfileID, StringComparison.OrdinalIgnoreCase));
- if (server != null)
- {
- server.Runtime.UpdateServerStatus(serverStatus, serverStatus != ServerStatus.Unknown);
- }
- }).Wait(token);
- }
- };
-
- Task.Run(() =>
- {
- app.PerformProfileShutdown(profile, false, false, false, false, token);
- _currentProfileCommands.Remove(profile.ProfileId);
- }, token);
-
- responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_ShutdownRequested"), profile.ServerName));
- }
-
- return responseList;
- }
-
- private static IList StopServer(string channelId, string profileIdOrAlias, CancellationToken token)
+ private static IList StopServer(string channelId, string profileIdOrAlias, bool shutdown, CancellationToken token)
{
if (string.IsNullOrWhiteSpace(profileIdOrAlias))
{
@@ -655,12 +550,13 @@ namespace ServerManagerTool.Utils
{
var app = new ServerApp(true)
{
+ BackupWorldFile = shutdown,
DeleteOldBackupFiles = !Config.Default.AutoBackup_EnableBackup,
OutputLogs = false,
+ PerformWorldSave = shutdown,
SendAlerts = true,
SendEmails = false,
- ServerProcess = ServerProcessType.Stop,
- ShutdownInterval = 0,
+ ServerProcess = shutdown ? ServerProcessType.Shutdown : ServerProcessType.Stop,
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
{
TaskUtils.RunOnUIThreadAsync(() =>
@@ -674,13 +570,19 @@ namespace ServerManagerTool.Utils
}
};
+ if (!shutdown)
+ app.ShutdownInterval = 0;
+
Task.Run(() =>
{
app.PerformProfileShutdown(profile, false, false, false, false, token);
_currentProfileCommands.Remove(profile.ProfileId);
}, token);
- responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_StopRequested"), profile.ServerName));
+ if (shutdown)
+ responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_ShutdownRequested"), profile.ServerName));
+ else
+ responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_StopRequested"), profile.ServerName));
}
return responseList;
diff --git a/src/ARKServerManager/Windows/ServerMonitorWindow.xaml b/src/ARKServerManager/Windows/ServerMonitorWindow.xaml
index 95ff243c..48bc10d1 100644
--- a/src/ARKServerManager/Windows/ServerMonitorWindow.xaml
+++ b/src/ARKServerManager/Windows/ServerMonitorWindow.xaml
@@ -6,9 +6,9 @@
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:sm="clr-namespace:ServerManagerTool"
- xmlns:smw="clr-namespace:ServerManagerTool.Windows"
xmlns:clib="clr-namespace:ServerManagerTool.Common.Lib;assembly=ServerManager.Common"
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
+ xmlns:controls="clr-namespace:ServerManagerTool.Common.Controls;assembly=ServerManager.Common"
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
xmlns:vm="clr-namespace:ServerManagerTool.Lib.ViewModel"
mc:Ignorable="d"
@@ -24,6 +24,13 @@
+
+
+
+
+
+
+
@@ -54,89 +61,49 @@
-
-
-
-
-
-
-
-
-
-
-