Automatic Management Changes

- rearranged the options so they are grouped correctly.
- added RestartIfShutdown property to ServerApp and changed to use when checking to restart server.
This commit is contained in:
Brett Hewitson 2022-08-08 20:01:42 +10:00
parent d9571943ad
commit 5532050c04
20 changed files with 157 additions and 92 deletions

View file

@ -1221,7 +1221,7 @@
<sys:String x:Key="ServerSettings_PeriodicUpdatesLabel">Schließt den Server in den Auto Aktualisierungszyklus ein</sys:String>
<sys:String x:Key="ServerSettings_PeriodicUpdatesTooltip">Wenn aktiviert, wird der Server während des automatischen Aktualisierungszyklus regelmäßig aktualisiert. Siehe die Einstellungen für die Optionen für die automatische Aktualisierung.</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownLabel">Startet den Server neu, wenn er heruntergefahren ist</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">Wenn aktiviert, wird der Server neu gestartet, auch wenn er für automatische Neustarts und automatische Updates heruntergefahren wird.</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">Wenn aktiviert, wird der Server neu gestartet, auch wenn er für automatische Updates heruntergefahren wird.</sys:String>
<!--#endregion-->
<!--#region Server Settings - Discord Bot Details -->

View file

@ -1318,7 +1318,7 @@
<sys:String x:Key="ServerSettings_PeriodicUpdatesLabel">Include server in the Auto-Update cycle</sys:String>
<sys:String x:Key="ServerSettings_PeriodicUpdatesTooltip">If enabled, the server will be periodically updated during the Auto-Update cycle. See the settings for Auto-Update options.</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownLabel">Restart server if shutdown</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">If enabled, the server will be restarted even if shutdown for Auto-Restarts and Auto-Updates.</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">If enabled, the server will be restarted even if shutdown for Auto-Updates.</sys:String>
<!--#endregion-->
<!--#region Server Settings - Discord Bot Details -->

View file

@ -1316,7 +1316,7 @@
<sys:String x:Key="ServerSettings_PeriodicUpdatesLabel">Inclure cycle de mise à jour automatique du serveur</sys:String>
<sys:String x:Key="ServerSettings_PeriodicUpdatesTooltip">Si cette option est activée, le serveur sera périodiquement mis à jour pendant le cycle de mise à jour automatique. Voir les paramètres pour les options de mise à jour automatique.</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownLabel">Redémarrer le serveur en cas d'arrêt</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">Si cette option est activée, le serveur sera redémarré même s'il est arrêté pour les redémarrages automatiques et les mises à jour automatiques.</sys:String>
<sys:String x:Key="ServerSettings_RestartIfShutdownTooltip">Si cette option est activée, le serveur sera redémarré même s'il est arrêté pour les mises à jour automatiques.</sys:String>
<!--#endregion-->
<!--#region Server Settings - Discord Bot Details -->

View file

@ -107,6 +107,7 @@ namespace ServerManagerTool.Lib
public bool OutputLogs { get; set; } = false;
public bool PerformWorldSave { get; set; } = Config.Default.ServerShutdown_EnableWorldSave;
public ProgressDelegate ProgressCallback { get; set; } = null;
public bool RestartIfShutdown { get; set; } = false;
public bool SendAlerts { get; set; } = false;
public bool SendEmails { get; set; } = false;
public bool SendShutdownMessages { get; set; } = Config.Default.ServerShutdown_SendShutdownMessages;
@ -332,7 +333,7 @@ namespace ServerManagerTool.Lib
// check if the server was previously running.
if (!_serverRunning)
{
if (_profile.AutoRestartIfShutdown)
if (RestartIfShutdown)
{
LogProfileMessage("Server was not running, server will be started as the setting to restart if shutdown is TRUE.");
}
@ -3295,7 +3296,8 @@ namespace ServerManagerTool.Lib
SendAlerts = SendAlerts,
SendEmails = SendEmails,
ServerProcess = ServerProcess,
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden,
RestartIfShutdown = profile.AutoRestartIfShutdown,
};
app.PerformProfileUpdate(branch, profile);
profileExitCodes.TryAdd(profile, app.ExitCode);
@ -3316,7 +3318,8 @@ namespace ServerManagerTool.Lib
SendAlerts = SendAlerts,
SendEmails = SendEmails,
ServerProcess = ServerProcess,
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden,
RestartIfShutdown = profile.AutoRestartIfShutdown,
};
app.PerformProfileUpdate(branch, profile);
profileExitCodes.TryAdd(profile, app.ExitCode);
@ -3483,7 +3486,8 @@ namespace ServerManagerTool.Lib
SendAlerts = true,
SendEmails = true,
ServerProcess = type,
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden,
RestartIfShutdown = performRestart,
};
exitCode = app.PerformProfileShutdown(profile, performRestart, performUpdate ? ServerUpdateType.ServerAndMods : ServerUpdateType.None, true, false, CancellationToken.None);

View file

@ -1372,20 +1372,17 @@
<StackPanel Margin="-8,0,2,0">
<GroupBox Header="{DynamicResource ServerSettings_ASMSettingLabel}" Style="{StaticResource GroupBoxStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" >
<StackPanel Orientation="Vertical">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.Style>
<Style TargetType="{x:Type Grid}">
@ -1400,15 +1397,14 @@
</Style>
</Grid.Style>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5,5,5,0">
<cctl:CheckBoxAndTextBlock Text="{DynamicResource ServerSettings_AutoStartServerLabel}" VerticalAlignment="Bottom" IsChecked="{Binding EnableAutoStart, Mode=TwoWay}" ToolTip="{DynamicResource ServerSettings_AutoStartServerTooltip}" HorizontalAlignment="Left"/>
<cctl:CheckBoxAndTextBlock Grid.Row="0" Grid.Column="0" Margin="5,5,5,0" Text="{DynamicResource ServerSettings_AutoStartServerLabel}" VerticalAlignment="Bottom" IsChecked="{Binding EnableAutoStart, Mode=TwoWay}" ToolTip="{DynamicResource ServerSettings_AutoStartServerTooltip}" HorizontalAlignment="Left"/>
<StackPanel Grid.Row="0" Grid.Column="1" Margin="5,5,5,0" Orientation="Horizontal">
<RadioButton GroupName="AutoStartServer" Margin="10,0,0,0" VerticalAlignment="Bottom" IsEnabled="{Binding EnableAutoStart}" IsChecked="{Binding AutoStartOnLogin, Converter={StaticResource InvertBooleanConverter}}" Content="{DynamicResource ServerSettings_AutoStartServerOnBootLabel}" ToolTip="{DynamicResource ServerSettings_AutoStartServerOnBootTooltip}"/>
<RadioButton GroupName="AutoStartServer" Margin="5,0,0,0" VerticalAlignment="Bottom" IsEnabled="{Binding EnableAutoStart}" IsChecked="{Binding AutoStartOnLogin}" Content="{DynamicResource ServerSettings_AutoStartServerOnLoginLabel}" ToolTip="{DynamicResource ServerSettings_AutoStartServerOnLoginTooltip}"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="5,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" >
<cctl:CheckBoxAndTextBlock Name="EnableAutoShutdown1Checkbox" IsChecked="{Binding EnableAutoShutdown1, Mode=TwoWay}" Text="{DynamicResource ServerSettings_EnableAutoShutdownLabel}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_EnableAutoShutdownTooltip}"/>
<cctl:CheckBoxAndTextBlock Grid.Row="1" Grid.Column="0" Margin="5,5,5,0" Name="EnableAutoShutdown1Checkbox" IsChecked="{Binding EnableAutoShutdown1, Mode=TwoWay}" Text="{DynamicResource ServerSettings_EnableAutoShutdownLabel}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_EnableAutoShutdownTooltip}"/>
<StackPanel Grid.Row="1" Grid.Column="1" Margin="5,5,5,0" Orientation="Horizontal" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" >
<TextBox Margin="10,0,0,0" Width="60" Height="20" IsEnabled="{Binding EnableAutoShutdown1}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_EnableAutoShutdownTooltip}">
<Validation.ErrorTemplate>
<ControlTemplate>
@ -1461,8 +1457,8 @@
<cctl:CheckBoxAndTextBlock IsEnabled="{Binding EnableAutoShutdown1}" IsChecked="{Binding RestartAfterShutdown1, Mode=TwoWay}" Text="{DynamicResource ServerSettings_RestartAfterShutdownLabel}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_RestartAfterShutdownTooltip}" FlowDirection="RightToLeft" Margin="10,0,0,0" />
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="5,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" >
<cctl:CheckBoxAndTextBlock Name="EnableAutoShutdown2Checkbox" IsChecked="{Binding EnableAutoShutdown2, Mode=TwoWay}" Text="{DynamicResource ServerSettings_EnableAutoShutdownLabel}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_EnableAutoShutdownTooltip}"/>
<cctl:CheckBoxAndTextBlock Grid.Row="2" Grid.Column="0" Margin="5,5,5,0" Name="EnableAutoShutdown2Checkbox" IsChecked="{Binding EnableAutoShutdown2, Mode=TwoWay}" Text="{DynamicResource ServerSettings_EnableAutoShutdownLabel}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_EnableAutoShutdownTooltip}"/>
<StackPanel Grid.Row="2" Grid.Column="1" Margin="5,5,5,0" Orientation="Horizontal" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" >
<TextBox Margin="10,0,0,0" Width="60" Height="20" IsEnabled="{Binding EnableAutoShutdown2}" VerticalAlignment="Bottom" ToolTip="{DynamicResource ServerSettings_EnableAutoShutdownTooltip}">
<Validation.ErrorTemplate>
<ControlTemplate>
@ -1516,10 +1512,22 @@
</StackPanel>
</Grid>
<cctl:CheckBoxAndTextBlock Grid.Row="1" Margin="5,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" IsChecked="{Binding EnableAutoBackup, Mode=TwoWay}" VerticalAlignment="Center" Text="{DynamicResource ServerSettings_PeriodicBackupsLabel}" ToolTip="{DynamicResource ServerSettings_PeriodicBackupsTooltip}" HorizontalAlignment="Left"/>
<cctl:CheckBoxAndTextBlock Grid.Row="2" Margin="5,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" IsChecked="{Binding EnableAutoUpdate, Mode=TwoWay}" VerticalAlignment="Center" Text="{DynamicResource ServerSettings_PeriodicUpdatesLabel}" ToolTip="{DynamicResource ServerSettings_PeriodicUpdatesTooltip}" HorizontalAlignment="Left"/>
<cctl:CheckBoxAndTextBlock Grid.Row="3" Margin="5,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" IsChecked="{Binding AutoRestartIfShutdown, Mode=TwoWay}" VerticalAlignment="Center" Text="{DynamicResource ServerSettings_RestartIfShutdownLabel}" ToolTip="{DynamicResource ServerSettings_RestartIfShutdownTooltip}" HorizontalAlignment="Left"/>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<cctl:CheckBoxAndTextBlock Grid.Row="0" Grid.Column="0" Margin="5,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" IsChecked="{Binding EnableAutoBackup, Mode=TwoWay}" VerticalAlignment="Center" Text="{DynamicResource ServerSettings_PeriodicBackupsLabel}" ToolTip="{DynamicResource ServerSettings_PeriodicBackupsTooltip}" HorizontalAlignment="Left"/>
<cctl:CheckBoxAndTextBlock Grid.Row="1" Grid.Column="0" Margin="5,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" IsChecked="{Binding EnableAutoUpdate, Mode=TwoWay}" VerticalAlignment="Center" Text="{DynamicResource ServerSettings_PeriodicUpdatesLabel}" ToolTip="{DynamicResource ServerSettings_PeriodicUpdatesTooltip}" HorizontalAlignment="Left"/>
<cctl:CheckBoxAndTextBlock Grid.Row="1" Grid.Column="1" Margin="10,5,5,0" IsEnabled="{Binding ElementName=EnableSOTFCheckbox, Path=IsChecked, Converter={StaticResource InvertBooleanConverter}}" IsChecked="{Binding AutoRestartIfShutdown, Mode=TwoWay}" VerticalAlignment="Center" Text="{DynamicResource ServerSettings_RestartIfShutdownLabel}" ToolTip="{DynamicResource ServerSettings_RestartIfShutdownTooltip}" HorizontalAlignment="Left"/>
</Grid>
</StackPanel>
</GroupBox>
</StackPanel>
</Expander>

View file

@ -448,7 +448,6 @@ namespace ServerManagerTool.Utils
_currentProfileCommands.Add(server.Profile.ProfileID, restart ? CommandType.Restart : CommandType.Start);
var profile = ServerProfileSnapshot.Create(server.Profile);
profile.AutoRestartIfShutdown = true;
profileList.Add(profile);
}
}
@ -462,6 +461,7 @@ namespace ServerManagerTool.Utils
SendAlerts = true,
SendEmails = false,
ServerProcess = ServerProcessType.Restart,
RestartIfShutdown = true,
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
{
TaskUtils.RunOnUIThreadAsync(() =>
@ -576,6 +576,7 @@ namespace ServerManagerTool.Utils
SendAlerts = true,
SendEmails = false,
ServerProcess = shutdown ? ServerProcessType.Shutdown : ServerProcessType.Stop,
RestartIfShutdown = false,
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
{
TaskUtils.RunOnUIThreadAsync(() =>
@ -644,8 +645,6 @@ namespace ServerManagerTool.Utils
{
foreach (var server in serverList)
{
var performRestart = false;
if (!server.Profile.AllowDiscordUpdate)
{
responseList.Add(string.Format(_globalizer.GetResourceString("DiscordBot_CommandDisabledProfile"), CommandType.Update, server.Profile.ProfileName));
@ -662,7 +661,6 @@ namespace ServerManagerTool.Utils
switch (server.Runtime.Status)
{
case ServerStatus.Running:
performRestart = true;
break;
case ServerStatus.Initializing:
@ -678,7 +676,6 @@ namespace ServerManagerTool.Utils
_currentProfileCommands.Add(server.Profile.ProfileID, CommandType.Update);
var profile = ServerProfileSnapshot.Create(server.Profile);
profile.RestartAfterShutdown1 = performRestart; // use this property to trigger a restart
profileList.Add(profile);
}
}
@ -692,6 +689,7 @@ namespace ServerManagerTool.Utils
SendAlerts = true,
SendEmails = false,
ServerProcess = ServerProcessType.Update,
RestartIfShutdown = false,
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
{
TaskUtils.RunOnUIThreadAsync(() =>
@ -707,7 +705,7 @@ namespace ServerManagerTool.Utils
Task.Run(() =>
{
app.PerformProfileShutdown(profile, profile.RestartAfterShutdown1, ServerUpdateType.ServerAndMods, false, false, token);
app.PerformProfileShutdown(profile, true, ServerUpdateType.ServerAndMods, false, false, token);
_currentProfileCommands.Remove(profile.ProfileId);
}, token);

View file

@ -5,14 +5,14 @@
<title>Ark Server Manager Version Feed</title>
<subtitle>This is the Ark Server Manager release version feed.</subtitle>
<link href="https://arkservermanager.freeforums.net/" />
<updated>2022-08-07T00:00:00Z</updated>
<updated>2022-08-08T00:00:00Z</updated>
<entry>
<id>urn:uuid:84E1DDF9-EFA4-4A8B-90DE-564AE3B3B633</id>
<title>1.1.437 (1.1.437.2)</title>
<summary>1.1.437.2</summary>
<title>1.1.437 (1.1.437.3)</title>
<summary>1.1.437.3</summary>
<link href="" />
<updated>2022-08-07T00:00:00Z</updated>
<updated>2022-08-08T00: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>
@ -20,6 +20,7 @@
<br/>
<ul>
<li>Server Update - updated the code to simplify which set of dedicated server files (Ark Survival Evolved or Ark: SotF) is required when performing server and mod file updates. Separate Cache folders will be maintained for each.</li>
<li>Automatic Management - rearranged the options so they are grouped correctly.</li>
<li>Auto-Start Server Option - added a new option selection for on Boot and on Login.</li>
</ul>
</p>

View file

@ -5,7 +5,30 @@
<title>Ark Server Manager Version Feed</title>
<subtitle>This is the Ark Server Manager beta version feed.</subtitle>
<link href="https://arkservermanager.freeforums.net/" />
<updated>2022-08-07T00:00:00Z</updated>
<updated>2022-08-08T00:00:00Z</updated>
<entry>
<id>urn:uuid:84E1DDF9-EFA4-4A8B-90DE-564AE3B3B633</id>
<title>1.1.437 (1.1.437.3)</title>
<summary>1.1.437.3</summary>
<link href="" />
<updated>2022-08-08T00: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>Automatic Management - rearranged the options so they are grouped correctly.</li>
</ul>
</p>
</div>
</content>
<author>
<name>bletch</name>
<email>bletch1971@hotmail.com</email>
</author>
</entry>
<entry>
<id>urn:uuid:84E1DDF9-EFA4-4A8B-90DE-564AE3B3B633</id>

View file

@ -1332,7 +1332,6 @@ namespace ServerManagerTool.Windows
_currentProfileCommands.Add(server.Profile.ProfileID, restart ? CommandType.Restart : CommandType.Start);
var profile = ServerProfileSnapshot.Create(server.Profile);
profile.AutoRestartIfShutdown = true;
profileList.Add(profile);
}
@ -1349,6 +1348,7 @@ namespace ServerManagerTool.Windows
SendEmails = false,
ShutdownReason = shutdownReason,
ServerProcess = ServerProcessType.Restart,
RestartIfShutdown = true,
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
{
TaskUtils.RunOnUIThreadAsync(() =>
@ -1492,6 +1492,7 @@ namespace ServerManagerTool.Windows
SendEmails = false,
ShutdownReason = shutdownReason,
ServerProcess = shutdown ? ServerProcessType.Shutdown : ServerProcessType.Stop,
RestartIfShutdown = false,
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
{
TaskUtils.RunOnUIThreadAsync(() =>
@ -1588,8 +1589,6 @@ namespace ServerManagerTool.Windows
foreach (var server in serverList)
{
var performRestart = false;
// check if another command is being run against the profile
if (_currentProfileCommands.ContainsKey(server.Profile.ProfileID))
{
@ -1600,7 +1599,6 @@ namespace ServerManagerTool.Windows
switch (server.Runtime.Status)
{
case ServerStatus.Running:
performRestart = true;
break;
case ServerStatus.Initializing:
@ -1616,7 +1614,6 @@ namespace ServerManagerTool.Windows
_currentProfileCommands.Add(server.Profile.ProfileID, CommandType.Update);
var profile = ServerProfileSnapshot.Create(server.Profile);
profile.RestartAfterShutdown1 = performRestart; // use this property to trigger a restart
profileList.Add(profile);
}
@ -1633,6 +1630,7 @@ namespace ServerManagerTool.Windows
SendEmails = false,
ShutdownReason = shutdownReason,
ServerProcess = ServerProcessType.Update,
RestartIfShutdown = false,
ServerStatusChangeCallback = (ServerStatus serverStatus) =>
{
TaskUtils.RunOnUIThreadAsync(() =>
@ -1650,7 +1648,7 @@ namespace ServerManagerTool.Windows
{
AddMessageBlockContent(string.Format(_globalizer.GetResourceString("DiscordBot_UpdateRequested"), profile.ServerName));
app.PerformProfileShutdown(profile, profile.RestartAfterShutdown1, updateModsOnly ? ServerUpdateType.Mods : ServerUpdateType.ServerAndMods, false, false, token);
app.PerformProfileShutdown(profile, true, updateModsOnly ? ServerUpdateType.Mods : ServerUpdateType.ServerAndMods, false, false, token);
Task.Delay(DELAY_PROCESSCOMPLETE).Wait();