Compare commits

..

5 Commits

Author SHA1 Message Date
John Gross
97da740e7e Catch errors in updater and fix loading error 2017-08-01 13:01:10 -07:00
John Gross
42bb24ca6a Hotfix for save issues 2017-08-01 12:31:49 -07:00
John Gross
2f3b6cdda7 Fix crashes and save issues 2017-07-31 13:12:01 -07:00
John Michael Gross
525b496774 Update README.md 2017-07-26 09:35:43 -07:00
John Michael Gross
562bb77dda Update README.md 2017-07-26 00:57:47 -07:00
13 changed files with 109 additions and 70 deletions

View File

@@ -1,4 +1,4 @@
# Torch 1.1.205.478
# Torch 1.1.207.7
* Notes
- This release makes significant changes to TorchConfig.xml. It has been renamed to Torch.cfg and has different options.
* Features

View File

@@ -10,17 +10,15 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
* Organized, easy to use configuration editor
* Extensible using the Torch plugin system
# Installation
* Get the latest Torch release here: https://github.com/TorchAPI/Torch/releases
* Unzip the Torch release into its own directory and run the executable. It will automatically download the SE DS and generate the other necessary files.
- If you already have a DS installed you can unzip the Torch files into the folder that contains the DedicatedServer64 folder.
# Building
To build Torch you must first have a complete SE Dedicated installation somewhere. Before you open the solution, run the Setup batch file and enter the path of that installation's DedicatedServer64 folder. The script will make a symlink to that folder so the Torch solution can find the DLL references it needs.
# Installation Guide
### Automatic (recommended)
* Unzip Torch to its own folder, run Torch.Server.exe and enter 'y' in the prompt for automatic updates. Torch will automatically download the Space Engineers files and generate all of the configs/folders necessary.
### Manual (for hosting companies or the paranoid)
* Install the Space Engineers DS and then unzip the Torch files into the server's DedicatedServer64 directory. It will automatically detect the manual install and disable automatic updates.
In both cases you will need to set the InstancePath in TorchConfig.xml to an existing dedicated server instance as Torch can't fully generate it on its own yet.
# Official Plugins
@@ -28,4 +26,5 @@ Install plugins by unzipping them into the 'Plugins' folder which should be in t
* [Essentials](https://github.com/TorchAPI/Essentials): Adds a slew of chat commands and other tools to help manage your server.
* [Concealment](https://github.com/TorchAPI/Concealment): Adds game logic and physics optimizations that significantly improve sim speed.
If you have a more enjoyable server experience because of Torch, please consider supporting us on [Patreon](https://www.patreon.com/bePatron?u=847269)!
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon.
[![Patreon](http://i.imgur.com/VzzIMgn.png)](https://www.patreon.com/bePatron?u=847269)!

View File

@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.207.7")]
[assembly: AssemblyFileVersion("1.0.207.7")]
[assembly: AssemblyVersion("1.0.213.390")]
[assembly: AssemblyFileVersion("1.0.213.390")]

View File

@@ -34,7 +34,10 @@ namespace Torch.Server.Managers
/// <inheritdoc />
public override void Init()
{
LoadInstance(Torch.Config.InstancePath);
MyFileSystem.ExePath = Path.Combine(Torch.GetManager<FilesystemManager>().TorchDirectory, "DedicatedServer64");
MyFileSystem.Init("Content", Torch.Config.InstancePath);
//Initializes saves path. Why this isn't in Init() we may never know.
MyFileSystem.InitUserSpecific(null);
}
public void LoadInstance(string path, bool validate = true)
@@ -45,6 +48,8 @@ namespace Torch.Server.Managers
MyFileSystem.Reset();
MyFileSystem.ExePath = Path.Combine(Torch.GetManager<FilesystemManager>().TorchDirectory, "DedicatedServer64");
MyFileSystem.Init("Content", path);
//Initializes saves path. Why this isn't in Init() we may never know.
MyFileSystem.InitUserSpecific(null);
var configPath = Path.Combine(path, CONFIG_NAME);
if (!File.Exists(configPath))
@@ -68,6 +73,8 @@ namespace Torch.Server.Managers
return;
}
ImportWorldConfig();
/*
if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
{
@@ -79,13 +86,13 @@ namespace Torch.Server.Managers
public void SelectWorld(string worldPath, bool modsOnly = true)
{
DedicatedConfig.LoadWorld = worldPath;
LoadWorldMods(modsOnly);
ImportWorldConfig(modsOnly);
}
private void LoadWorldMods(bool modsOnly = true)
private void ImportWorldConfig(bool modsOnly = true)
{
if (DedicatedConfig.LoadWorld == null)
if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
return;
var sandboxPath = Path.Combine(DedicatedConfig.LoadWorld, "Sandbox.sbc");
@@ -93,23 +100,31 @@ namespace Torch.Server.Managers
if (!File.Exists(sandboxPath))
return;
MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
if (checkpoint == null)
try
{
Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {TorchBase.Instance.Config.InstancePath})");
return;
MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
if (checkpoint == null)
{
Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {TorchBase.Instance.Config.InstancePath})");
return;
}
var sb = new StringBuilder();
foreach (var mod in checkpoint.Mods)
sb.AppendLine(mod.PublishedFileId.ToString());
DedicatedConfig.Mods = sb.ToString();
Log.Debug("Loaded mod list from world");
if (!modsOnly)
DedicatedConfig.SessionSettings = new SessionSettingsViewModel(checkpoint.Settings);
}
catch (Exception e)
{
Log.Error($"Error loading mod list from world, verify that your mod list is accurate. '{DedicatedConfig.LoadWorld}'.");
Log.Error(e);
}
var sb = new StringBuilder();
foreach (var mod in checkpoint.Mods)
sb.AppendLine(mod.PublishedFileId.ToString());
DedicatedConfig.Mods = sb.ToString();
Log.Info("Loaded mod list from world");
if (!modsOnly)
DedicatedConfig.SessionSettings = new SessionSettingsViewModel(checkpoint.Settings);
}
public void SaveConfig()

View File

@@ -84,10 +84,14 @@ namespace Torch.Server
{
var pid = int.Parse(_config.WaitForPID);
var waitProc = Process.GetProcessById(pid);
_log.Warn($"Waiting for process {pid} to exit.");
waitProc.WaitForExit();
_log.Info("Continuing in 5 seconds.");
Thread.Sleep(5000);
if (!waitProc.HasExited)
{
_log.Warn($"Killing old process {pid}.");
waitProc.Kill();
}
}
catch
{

View File

@@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.1.207.7")]
[assembly: AssemblyFileVersion("1.1.207.7")]
[assembly: AssemblyVersion("1.1.213.390")]
[assembly: AssemblyFileVersion("1.1.213.390")]

View File

@@ -77,10 +77,9 @@ namespace Torch.Server
MySessionComponentExtDebug.ForceDisable = true;
MyPerServerSettings.AppId = 244850;
MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion;
MyObjectBuilderSerializer.RegisterFromAssembly(typeof(MyObjectBuilder_CheckpointSerializer).Assembly);
InvokeBeforeRun();
MyObjectBuilderSerializer.RegisterFromAssembly(typeof(MyObjectBuilder_CheckpointSerializer).Assembly);
MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly);
MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly);
MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly);
@@ -88,6 +87,7 @@ namespace Torch.Server
MyPlugins.Load();
MyGlobalTypeMetadata.Static.Init();
GetManager<InstanceManager>().LoadInstance(Config.InstancePath);
Plugins.LoadPlugins();
}
@@ -143,6 +143,8 @@ namespace Torch.Server
VRage.Service.ExitListenerSTA.OnExit += delegate { MySandboxGame.Static?.Exit(); };
base.Start();
//Stops RunInternal from calling MyFileSystem.InitUserSpecific(null), we call it in InstanceManager.
MySandboxGame.IsReloading = true;
runInternal.Invoke(null, null);
MySandboxGame.Log.Close();

View File

@@ -39,7 +39,7 @@
</StackPanel>
<TabControl Grid.Row="1" Height="Auto" x:Name="TabControl" Margin="5,0,5,5">
<TabItem Header="Configuration">
<Grid>
<Grid IsEnabled="{Binding IsRunning, Converter={StaticResource InverseBool}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>

View File

@@ -40,7 +40,7 @@ namespace Torch.Commands
public bool IsCommand(string command)
{
return command.Length > 1 && command[0] == Prefix;
return !string.IsNullOrEmpty(command) && command[0] == Prefix;
}
public void RegisterCommandModule(Type moduleType, ITorchPlugin plugin = null)

View File

@@ -120,6 +120,9 @@ namespace Torch.Managers
/// <inheritdoc />
public void SendMessage(string message, string author = "Server", long playerId = 0, string font = MyFontEnum.Red)
{
if (string.IsNullOrEmpty(message))
return;
ChatHistory.Add(new ChatMessage(DateTime.Now, 0, author, message));
var commands = Torch.GetManager<CommandManager>();
if (commands.IsCommand(message))

View File

@@ -126,8 +126,7 @@ namespace Torch.Managers
}
catch (Exception ex)
{
_log.Fatal(ex);
_log.Fatal(ex, "~Error processing event!");
_log.Error(ex);
//crash after logging, bad things could happen if we continue on with bad data
throw;
}
@@ -200,8 +199,8 @@ namespace Torch.Managers
}
catch (Exception ex)
{
_log.Fatal(ex);
_log.Fatal(ex, "Error when returning control to game server!");
_log.Error(ex, "Error processing network event!");
_log.Error(ex);
//crash after logging, bad things could happen if we continue on with bad data
throw;
}

View File

@@ -121,9 +121,10 @@ namespace Torch.Managers
commands.RegisterPluginCommands(plugin);
}
catch
catch (Exception e)
{
_log.Error($"Error loading plugin '{type.FullName}'");
_log.Error(e);
throw;
}
}

View File

@@ -67,27 +67,35 @@ namespace Torch.Managers
if (!Torch.Config.GetPluginUpdates)
return;
var name = manifest.Repository.Split('/');
if (name.Length != 2)
try
{
_log.Error($"'{manifest.Repository}' is not a valid GitHub repository.");
return;
}
var name = manifest.Repository.Split('/');
if (name.Length != 2)
{
_log.Error($"'{manifest.Repository}' is not a valid GitHub repository.");
return;
}
var currentVersion = new Version(manifest.Version);
var releaseInfo = await GetLatestRelease(name[0], name[1]).ConfigureAwait(false);
if (releaseInfo.Item1 > currentVersion)
{
_log.Warn($"Updating {manifest.Repository} from version {currentVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, $"{name[0]}_{name[1]}.zip");
var updatePath = Path.Combine(_torchDir, "Plugins");
await new WebClient().DownloadFileTaskAsync(new Uri(releaseInfo.Item2), updateName).ConfigureAwait(false);
UpdateFromZip(updateName, updatePath);
File.Delete(updateName);
var currentVersion = new Version(manifest.Version);
var releaseInfo = await GetLatestRelease(name[0], name[1]).ConfigureAwait(false);
if (releaseInfo.Item1 > currentVersion)
{
_log.Warn($"Updating {manifest.Repository} from version {currentVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, $"{name[0]}_{name[1]}.zip");
var updatePath = Path.Combine(_torchDir, "Plugins");
await new WebClient().DownloadFileTaskAsync(new Uri(releaseInfo.Item2), updateName).ConfigureAwait(false);
UpdateFromZip(updateName, updatePath);
File.Delete(updateName);
}
else
{
_log.Info($"{manifest.Repository} is up to date. ({currentVersion})");
}
}
else
catch (Exception e)
{
_log.Info($"{manifest.Repository} is up to date. ({currentVersion})");
_log.Error($"An error occured downloading the plugin update for {manifest.Repository}.");
_log.Error(e);
}
}
@@ -96,18 +104,26 @@ namespace Torch.Managers
if (!Torch.Config.GetTorchUpdates)
return;
var releaseInfo = await GetLatestRelease("TorchAPI", "Torch").ConfigureAwait(false);
if (releaseInfo.Item1 > Torch.TorchVersion)
try
{
_log.Warn($"Updating Torch from version {Torch.TorchVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, "torchupdate.zip");
new WebClient().DownloadFile(new Uri(releaseInfo.Item2), updateName);
UpdateFromZip(updateName, _torchDir);
File.Delete(updateName);
var releaseInfo = await GetLatestRelease("TorchAPI", "Torch").ConfigureAwait(false);
if (releaseInfo.Item1 > Torch.TorchVersion)
{
_log.Warn($"Updating Torch from version {Torch.TorchVersion} to version {releaseInfo.Item1}");
var updateName = Path.Combine(_fsManager.TempDirectory, "torchupdate.zip");
new WebClient().DownloadFile(new Uri(releaseInfo.Item2), updateName);
UpdateFromZip(updateName, _torchDir);
File.Delete(updateName);
}
else
{
_log.Info("Torch is up to date.");
}
}
else
catch (Exception e)
{
_log.Info("Torch is up to date.");
_log.Error("An error occured downloading the Torch update.");
_log.Error(e);
}
}