diff --git a/Torch.API/ITorchBase.cs b/Torch.API/ITorchBase.cs
index 779d004..9b1a335 100644
--- a/Torch.API/ITorchBase.cs
+++ b/Torch.API/ITorchBase.cs
@@ -104,7 +104,7 @@ namespace Torch.API
///
/// Restart the Torch instance, blocking until the restart has been performed.
///
- void Restart();
+ void Restart(bool save = true);
///
/// Initializes a save of the game.
diff --git a/Torch.Server/TorchServer.cs b/Torch.Server/TorchServer.cs
index 0f593f3..503a277 100644
--- a/Torch.Server/TorchServer.cs
+++ b/Torch.Server/TorchServer.cs
@@ -152,14 +152,15 @@ namespace Torch.Server
///
/// Restart the program.
///
- public override void Restart()
+ public override void Restart(bool save = true)
{
if (Config.DisconnectOnRestart)
{
ModCommunication.SendMessageToClients(new JoinServerMessage("0.0.0.0:25555"));
+ Log.Info("Ejected all players from server for restart.");
}
- if (IsRunning)
+ if (IsRunning && save)
Save().ContinueWith(DoRestart, this, TaskContinuationOptions.RunContinuationsAsynchronously);
else
DoRestart(null, this);
diff --git a/Torch/Commands/TorchCommands.cs b/Torch/Commands/TorchCommands.cs
index accb888..05c6867 100644
--- a/Torch/Commands/TorchCommands.cs
+++ b/Torch/Commands/TorchCommands.cs
@@ -8,6 +8,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
+using NLog;
using Sandbox.Game.Multiplayer;
using Sandbox.ModAPI;
using Steamworks;
@@ -28,6 +29,7 @@ namespace Torch.Commands
{
private static bool _restartPending = false;
private static bool _cancelRestart = false;
+ private static readonly Logger Log = LogManager.GetCurrentClassLogger();
[Command("whatsmyip")]
[Permission(MyPromoteLevel.None)]
@@ -176,6 +178,7 @@ namespace Torch.Commands
}
_restartPending = true;
+
Task.Run(() =>
{
var countdown = RestartCountdown(countdownSeconds, save).GetEnumerator();
@@ -232,15 +235,18 @@ namespace Torch.Commands
else
{
if (save)
- Context.Torch.Save().ContinueWith(x => Restart());
- else
- Restart();
+ {
+ Log.Info("Savin game before restart.");
+ Context.Torch.CurrentSession.Managers.GetManager()
+ .SendMessageAsSelf($"Saving game before restart.");
+ }
+
+ Log.Info("Restarting server.");
+ Context.Torch.Invoke(() => Context.Torch.Restart(save));
yield break;
}
}
-
- void Restart() => Context.Torch.Invoke(() => Context.Torch.Restart());
}
private string Pluralize(int num)
diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs
index edf8277..8ad7f16 100644
--- a/Torch/TorchBase.cs
+++ b/Torch/TorchBase.cs
@@ -427,7 +427,7 @@ namespace Torch
}
///
- public abstract void Restart();
+ public abstract void Restart(bool save = true);
///
public virtual void Init(object gameInstance)