add optional restart save timeout

This commit is contained in:
zznty
2024-11-09 19:28:27 +07:00
parent d15985e918
commit 7ea0a4f8b9
3 changed files with 6 additions and 1 deletions

View File

@@ -121,6 +121,9 @@ public class TorchConfig : ViewModel, ITorchConfig
[Display(Name = "Packages", Description = "Packages to install and use.", GroupName = "Server")]
public List<string> Packages { get; set; } = new();
[Display(Name = "Restart Save Timeout", Description = "Timeout for save operation on restart in seconds.", GroupName = "Server")]
public int RestartSaveTimeout { get; set; }
// for backward compatibility
public void Save(string path = null) => Initializer.Instance?.ConfigPersistent?.Save(path);

View File

@@ -248,7 +248,8 @@ namespace Torch.Server
{
if (save)
{
var saveResult = Save(exclusive: true).Result;
var saveResult = Save(Config.RestartSaveTimeout == 0 ? -1 : Config.RestartSaveTimeout,
exclusive: true).Result;
if (saveResult is not (GameSaveResult.Success or GameSaveResult.TimedOut))
{
Log.Error("Save failed due to {Reason}. Restart aborted!", saveResult);