Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
83dfc7152f | ||
d7e5f53e4f | |||
9b08b39a1f |
@@ -30,9 +30,8 @@ namespace Torch.Server
|
||||
private bool _init;
|
||||
private const string TOOL_DIR = "tool";
|
||||
private const string TOOL_ZIP = "temp.zip";
|
||||
private static readonly string TOOL_EXE = "DepotDownloader.exe";
|
||||
private const string TOOL_ARGS = "-app 298740 -depot {1} -dir \"{0}\" -manifest {2}";
|
||||
private static readonly int[] Depots = { 298741, 1004 };
|
||||
private static readonly string TOOL_EXE = "steamcmd.exe";
|
||||
private const string TOOL_ARGS = "+force_install_dir \"{0}\" +login anonymous +app_update 298740 +quit";
|
||||
private TorchServer _server;
|
||||
|
||||
internal Persistent<TorchConfig> ConfigPersistent { get; }
|
||||
@@ -131,7 +130,7 @@ namespace Torch.Server
|
||||
|
||||
public static async Task RunSteamCmdAsync(IConfiguration configuration)
|
||||
{
|
||||
var log = LogManager.GetLogger("SteamTool");
|
||||
var log = LogManager.GetLogger("SteamCMD");
|
||||
|
||||
var path = configuration.GetValue<string>("steamToolPath") ?? ApplicationContext.Current.TorchDirectory
|
||||
.CreateSubdirectory(TOOL_DIR).FullName;
|
||||
@@ -141,39 +140,32 @@ namespace Torch.Server
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
var steamCmdExePath = Path.Combine(path, TOOL_EXE);
|
||||
if (!File.Exists(steamCmdExePath))
|
||||
var toolExe = Path.Combine(path, TOOL_EXE);
|
||||
if (!File.Exists(toolExe))
|
||||
{
|
||||
try
|
||||
{
|
||||
log.Info("Downloading Steam Tool.");
|
||||
log.Info("Downloading SteamCMD.");
|
||||
using (var client = new HttpClient())
|
||||
await using (var file = File.Create(TOOL_ZIP))
|
||||
await using (var stream = await client.GetStreamAsync("https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.4.7/depotdownloader-2.4.7.zip"))
|
||||
await using (var stream = await client.GetStreamAsync("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip"))
|
||||
await stream.CopyToAsync(file);
|
||||
|
||||
ZipFile.ExtractToDirectory(TOOL_ZIP, path);
|
||||
File.Delete(TOOL_ZIP);
|
||||
log.Info("Steam Tool downloaded successfully!");
|
||||
log.Info("SteamCMD downloaded successfully!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Error(e, "Failed to download Steam Tool, unable to update the DS.");
|
||||
log.Error(e, "Failed to download SteamCMD, unable to update the DS.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log.Info("Checking for DS updates.");
|
||||
foreach (var depot in Depots)
|
||||
var steamCmdProc = new ProcessStartInfo(toolExe)
|
||||
{
|
||||
await DownloadDepot(depot);
|
||||
}
|
||||
|
||||
async Task DownloadDepot(int depotId)
|
||||
{
|
||||
var steamCmdProc = new ProcessStartInfo(steamCmdExePath)
|
||||
{
|
||||
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../"), depotId, "14195799952783859"),
|
||||
Arguments = string.Format(TOOL_ARGS, configuration.GetValue("gamePath", "../")),
|
||||
WorkingDirectory = path,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
@@ -186,5 +178,4 @@ namespace Torch.Server
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -69,6 +69,14 @@ namespace Torch.Server
|
||||
|
||||
_simUpdateTimer.Elapsed += SimUpdateElapsed;
|
||||
_simUpdateTimer.Start();
|
||||
|
||||
Console.CancelKeyPress += (_, _) =>
|
||||
{
|
||||
if (State == ServerState.Running)
|
||||
Stop();
|
||||
|
||||
Environment.Exit(0);
|
||||
};
|
||||
}
|
||||
|
||||
private void SimUpdateElapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
@@ -239,9 +247,14 @@ namespace Torch.Server
|
||||
StopInternal();
|
||||
LogManager.Flush();
|
||||
|
||||
if (
|
||||
#if DEBUG
|
||||
Environment.Exit(0);
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
true ||
|
||||
#endif
|
||||
ApplicationContext.Current.IsService
|
||||
)
|
||||
Environment.Exit(0);
|
||||
|
||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||
|
||||
|
@@ -116,7 +116,7 @@ namespace Torch.Server
|
||||
if (_server?.State == ServerState.Running)
|
||||
_server.Stop();
|
||||
|
||||
Process.GetCurrentProcess().Kill();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -372,10 +372,10 @@ namespace Torch
|
||||
/// <inheritdoc />
|
||||
public virtual void Stop()
|
||||
{
|
||||
LogManager.Flush();
|
||||
Game.SignalStop();
|
||||
if (!Game.WaitFor(VRageGame.GameState.Stopped))
|
||||
if (!Game.WaitFor(VRageGame.GameState.Stopped, TimeSpan.FromSeconds(Config.TickTimeout)))
|
||||
Log.Warn("Failed to wait for the game to be stopped");
|
||||
LogManager.Flush();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
Reference in New Issue
Block a user