Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
aa7426dfa2 | ||
![]() |
7ea0a4f8b9 | ||
![]() |
d15985e918 | ||
![]() |
58340e0f5d | ||
![]() |
67bb3fd00c | ||
90546a78c2 | |||
![]() |
d301955609 | ||
![]() |
264daf7515 |
37
.github/workflows/release.yaml
vendored
37
.github/workflows/release.yaml
vendored
@@ -5,7 +5,6 @@ on:
|
|||||||
branches: [master]
|
branches: [master]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BUILD_CONFIGURATION: Release
|
|
||||||
DOTNET_NOLOGO: true
|
DOTNET_NOLOGO: true
|
||||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||||
|
|
||||||
@@ -33,36 +32,24 @@ jobs:
|
|||||||
name: Build and Publish Nuget
|
name: Build and Publish Nuget
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [get-version]
|
needs: [get-version]
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
project: [ Torch.API, Torch, Torch.Server ]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
name: Checkout
|
name: Checkout
|
||||||
|
|
||||||
- uses: actions/setup-dotnet@v3
|
- uses: actions/setup-dotnet@v4
|
||||||
name: Setup dotnet
|
name: Setup dotnet
|
||||||
with:
|
|
||||||
dotnet-version: '8.0.x'
|
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore Torch.Server/Torch.Server.csproj --locked-mode
|
run: dotnet restore ${{ matrix.project }}/${{ matrix.project }}.csproj --locked-mode
|
||||||
|
|
||||||
- name: Build
|
- name: Pack
|
||||||
run: dotnet build Torch.Server/Torch.Server.csproj --no-restore -c ${{ env.BUILD_CONFIGURATION }} -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}"
|
run: dotnet pack ${{ matrix.project }}/${{ matrix.project }}.csproj -o pack --no-restore -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}"
|
||||||
|
|
||||||
- run: dotnet pack -c Release ./Torch.API/Torch.API.csproj -o pack -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}" --no-build
|
- name: Push
|
||||||
- run: dotnet pack -c Release ./Torch/Torch.csproj -o pack -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}" --no-build
|
run: dotnet nuget push -s https://ng.zznty.ru/v3/index.json -k ${{ secrets.NUGET_API_KEY }} ./pack/${{ matrix.project }}.${{ needs.get-version.outputs.version }}.nupkg
|
||||||
- run: dotnet pack -c Release ./Torch.Server/Torch.Server.csproj -o pack -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}" --no-build
|
|
||||||
|
|
||||||
- name: Install Sleet
|
|
||||||
run: dotnet tool install -g sleet --version 5.1.3
|
|
||||||
- name: Push Nuget Package
|
|
||||||
env:
|
|
||||||
SLEET_FEED_TYPE: s3
|
|
||||||
SLEET_FEED_PATH: https://nuget.storage.yandexcloud.net
|
|
||||||
SLEET_FEED_BUCKETNAME: nuget
|
|
||||||
SLEET_FEED_SERVICEURL: https://storage.yandexcloud.net
|
|
||||||
SLEET_FEED_ACCESSKEYID: ${{ secrets.S3_KEY_ID }}
|
|
||||||
SLEET_FEED_SECRETACCESSKEY: ${{ secrets.S3_KEY }}
|
|
||||||
run: /root/.dotnet/tools/sleet push ./pack
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build and Publish Package
|
name: Build and Publish Package
|
||||||
@@ -72,16 +59,14 @@ jobs:
|
|||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@master
|
||||||
name: Checkout
|
name: Checkout
|
||||||
|
|
||||||
- uses: actions/setup-dotnet@v3
|
- uses: actions/setup-dotnet@v4
|
||||||
name: Setup dotnet
|
name: Setup dotnet
|
||||||
with:
|
|
||||||
dotnet-version: '8.0.x'
|
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore Torch.Server/Torch.Server.csproj --locked-mode -r win-x64
|
run: dotnet restore Torch.Server/Torch.Server.csproj --locked-mode -r win-x64
|
||||||
|
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: dotnet publish Torch.Server/Torch.Server.csproj --no-restore --sc -r win-x64 -c ${{ env.BUILD_CONFIGURATION }} -o ./publish -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}"
|
run: dotnet publish Torch.Server/Torch.Server.csproj --no-restore --sc -r win-x64 -o ./publish -p:Version="${{ needs.get-version.outputs.version }}" -p:AssemblyVersion="${{ needs.get-version.outputs.version }}"
|
||||||
|
|
||||||
- uses: vimtor/action-zip@v1
|
- uses: vimtor/action-zip@v1
|
||||||
name: Zip Release
|
name: Zip Release
|
||||||
|
@@ -11,7 +11,7 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
|
|||||||
* Extensible using the Torch plugin system
|
* Extensible using the Torch plugin system
|
||||||
|
|
||||||
### Fork Difference
|
### Fork Difference
|
||||||
* .NET 6.0 runtime
|
* .NET 8.0 runtime
|
||||||
* Optimized in-game scripts (also newer compiler & language versions)
|
* Optimized in-game scripts (also newer compiler & language versions)
|
||||||
* Better configuration via cli arguments, environment variables or xml config
|
* Better configuration via cli arguments, environment variables or xml config
|
||||||
* Designed to run multiple instance from same install directory without having you to waste disk space
|
* Designed to run multiple instance from same install directory without having you to waste disk space
|
||||||
@@ -19,7 +19,9 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
|
|||||||
|
|
||||||
### Discord
|
### Discord
|
||||||
|
|
||||||
If you have any questions or issues please join our [discord](https://discord.gg/UyYFSe3TyQ)
|
If you have any questions or issues please join our discord
|
||||||
|
|
||||||
|
[](https://discord.gg/VAb2zgXHAN)
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ If you have any questions or issues please join our [discord](https://discord.gg
|
|||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
|
||||||
As a regular dotnet project with cli by running `dotnet build Torch.Server/Torch.Server.csproj`, with VS 2022 or higher, with JB Rider or Fleet.
|
As a regular dotnet project with cli by running `dotnet build Torch.Server/Torch.Server.csproj`, with VS 2022 or higher or JB Rider.
|
||||||
|
|
||||||
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon. (https://www.patreon.com/TorchSE)
|
If you have a more enjoyable server experience because of Torch, please consider supporting us on Patreon. (https://www.patreon.com/TorchSE)
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@ namespace Torch
|
|||||||
string LoginToken { get; set; }
|
string LoginToken { get; set; }
|
||||||
UpdateSource UpdateSource { get; set; }
|
UpdateSource UpdateSource { get; set; }
|
||||||
List<string> Packages { get; set; }
|
List<string> Packages { get; set; }
|
||||||
|
int RestartSaveTimeout { get; set; }
|
||||||
|
|
||||||
void Save(string path = null);
|
void Save(string path = null);
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,11 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The save operation timed out
|
/// The save operation timed out
|
||||||
/// </summary>
|
/// </summary>
|
||||||
TimedOut = -5
|
TimedOut = -5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Another save operation is in progress
|
||||||
|
/// </summary>
|
||||||
|
ConcurrentSaveInProgress = -6
|
||||||
}
|
}
|
||||||
}
|
}
|
39
Torch.Server/ApplicationRestartHelper.cs
Normal file
39
Torch.Server/ApplicationRestartHelper.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Torch.Server;
|
||||||
|
|
||||||
|
internal static class ApplicationRestartHelper
|
||||||
|
{
|
||||||
|
public static void RestartApplication()
|
||||||
|
{
|
||||||
|
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||||
|
|
||||||
|
var args = Environment.GetCommandLineArgs().ToList();
|
||||||
|
|
||||||
|
args.RemoveAt(0); // dll entry path
|
||||||
|
|
||||||
|
args.RemoveConfigItem("--tempAutostart");
|
||||||
|
args.RemoveConfigItem("--waitForPid");
|
||||||
|
|
||||||
|
args.AddRange([
|
||||||
|
"--waitForPid", Environment.ProcessId.ToString(),
|
||||||
|
"--tempAutostart", "true"
|
||||||
|
]);
|
||||||
|
|
||||||
|
Process.Start(new ProcessStartInfo(exe, args));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RemoveConfigItem(this List<string> list, string item)
|
||||||
|
{
|
||||||
|
var index = list.BinarySearch(item, StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (index < 0) return;
|
||||||
|
|
||||||
|
list.RemoveAt(index);
|
||||||
|
list.RemoveAt(index);
|
||||||
|
}
|
||||||
|
}
|
@@ -94,26 +94,10 @@ namespace Torch.Server
|
|||||||
|
|
||||||
_server.Init();
|
_server.Init();
|
||||||
|
|
||||||
var uiThread = new Thread(() =>
|
if (!Config.Autostart && !Config.TempAutostart) return;
|
||||||
{
|
|
||||||
var ui = new TorchUI(_server);
|
|
||||||
|
|
||||||
SynchronizationContext.SetSynchronizationContext(
|
Config.TempAutostart = false;
|
||||||
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
|
_server.Start();
|
||||||
|
|
||||||
ui.ShowDialog();
|
|
||||||
});
|
|
||||||
|
|
||||||
uiThread.SetApartmentState(ApartmentState.STA);
|
|
||||||
uiThread.Start();
|
|
||||||
|
|
||||||
if (Config.Autostart || Config.TempAutostart)
|
|
||||||
{
|
|
||||||
Config.TempAutostart = false;
|
|
||||||
_server.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
uiThread.Join();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
Torch.Server/Managers/UiManager.cs
Normal file
37
Torch.Server/Managers/UiManager.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Torch.Managers;
|
||||||
|
|
||||||
|
namespace Torch.Server.Managers;
|
||||||
|
|
||||||
|
public class UiManager(TorchServer torchInstance) : Manager(torchInstance)
|
||||||
|
{
|
||||||
|
[CanBeNull] private Thread _uiThread;
|
||||||
|
[CanBeNull] private Dispatcher _dispatcher;
|
||||||
|
|
||||||
|
public override void Attach()
|
||||||
|
{
|
||||||
|
_uiThread = new Thread(() =>
|
||||||
|
{
|
||||||
|
var ui = new TorchUI(torchInstance);
|
||||||
|
|
||||||
|
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||||
|
|
||||||
|
SynchronizationContext.SetSynchronizationContext(
|
||||||
|
new DispatcherSynchronizationContext(_dispatcher));
|
||||||
|
|
||||||
|
ui.ShowDialog();
|
||||||
|
});
|
||||||
|
|
||||||
|
_uiThread.SetApartmentState(ApartmentState.STA);
|
||||||
|
_uiThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Detach()
|
||||||
|
{
|
||||||
|
_dispatcher?.InvokeShutdown();
|
||||||
|
if (Thread.CurrentThread != _uiThread)
|
||||||
|
_uiThread?.Join();
|
||||||
|
}
|
||||||
|
}
|
@@ -114,14 +114,17 @@ public class TorchConfig : ViewModel, ITorchConfig
|
|||||||
|
|
||||||
public UpdateSource UpdateSource { get; set; } = new()
|
public UpdateSource UpdateSource { get; set; } = new()
|
||||||
{
|
{
|
||||||
Repository = "PveTeam/Torch",
|
Repository = "PvE/Torch",
|
||||||
Url = "https://api.github.com",
|
Url = "https://git.zznty.ru/api/v1",
|
||||||
SourceType = UpdateSourceType.Github
|
SourceType = UpdateSourceType.Github
|
||||||
};
|
};
|
||||||
|
|
||||||
[Display(Name = "Packages", Description = "Packages to install and use.", GroupName = "Server")]
|
[Display(Name = "Packages", Description = "Packages to install and use.", GroupName = "Server")]
|
||||||
public List<string> Packages { get; set; } = new();
|
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
|
// for backward compatibility
|
||||||
public void Save(string path = null) => Initializer.Instance?.ConfigPersistent?.Save(path);
|
public void Save(string path = null) => Initializer.Instance?.ConfigPersistent?.Save(path);
|
||||||
}
|
}
|
@@ -56,6 +56,8 @@ namespace Torch.Server
|
|||||||
if (config.EntityManagerEnabled)
|
if (config.EntityManagerEnabled)
|
||||||
AddManager(new EntityControlManager(this));
|
AddManager(new EntityControlManager(this));
|
||||||
AddManager(new RemoteAPIManager(this));
|
AddManager(new RemoteAPIManager(this));
|
||||||
|
if (!ApplicationContext.Current.IsService && !config.NoGui)
|
||||||
|
AddManager(new UiManager(this));
|
||||||
|
|
||||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||||
sessionManager.AddFactory(_ => new MultiplayerManagerDedicated(this));
|
sessionManager.AddFactory(_ => new MultiplayerManagerDedicated(this));
|
||||||
@@ -185,7 +187,7 @@ namespace Torch.Server
|
|||||||
|
|
||||||
if (IsRunning || HasRun)
|
if (IsRunning || HasRun)
|
||||||
{
|
{
|
||||||
Restart();
|
Restart(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,7 +248,8 @@ namespace Torch.Server
|
|||||||
{
|
{
|
||||||
if (save)
|
if (save)
|
||||||
{
|
{
|
||||||
var saveResult = Save().Result;
|
var saveResult = Save(Config.RestartSaveTimeout == 0 ? -1 : Config.RestartSaveTimeout,
|
||||||
|
exclusive: true).Result;
|
||||||
if (saveResult is not (GameSaveResult.Success or GameSaveResult.TimedOut))
|
if (saveResult is not (GameSaveResult.Success or GameSaveResult.TimedOut))
|
||||||
{
|
{
|
||||||
Log.Error("Save failed due to {Reason}. Restart aborted!", saveResult);
|
Log.Error("Save failed due to {Reason}. Restart aborted!", saveResult);
|
||||||
@@ -267,24 +270,7 @@ namespace Torch.Server
|
|||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
ApplicationRestartHelper.RestartApplication();
|
||||||
|
|
||||||
var args = Environment.GetCommandLineArgs();
|
|
||||||
|
|
||||||
for (var i = 0; i < args.Length; i++)
|
|
||||||
{
|
|
||||||
if (args[i].Contains(' '))
|
|
||||||
args[i] = $"\"{args[i]}\"";
|
|
||||||
|
|
||||||
if (!args[i].Contains("--tempAutostart", StringComparison.InvariantCultureIgnoreCase) &&
|
|
||||||
!args[i].Contains("--waitForPid", StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
args[i] = string.Empty;
|
|
||||||
args[++i] = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
Process.Start(exe, $"--waitForPid {Environment.ProcessId} --tempAutostart true {string.Join(" ", args)}");
|
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
Name = "Restart thread"
|
Name = "Restart thread"
|
||||||
|
@@ -33,24 +33,7 @@ internal class UnhandledExceptionHandler
|
|||||||
Console.WriteLine("Restarting in 5 seconds.");
|
Console.WriteLine("Restarting in 5 seconds.");
|
||||||
Thread.Sleep(5000);
|
Thread.Sleep(5000);
|
||||||
|
|
||||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
ApplicationRestartHelper.RestartApplication();
|
||||||
|
|
||||||
var args = Environment.GetCommandLineArgs();
|
|
||||||
|
|
||||||
for (var i = 0; i < args.Length; i++)
|
|
||||||
{
|
|
||||||
if (args[i].Contains(' '))
|
|
||||||
args[i] = $"\"{args[i]}\"";
|
|
||||||
|
|
||||||
if (!args[i].Contains("--tempAutostart", StringComparison.InvariantCultureIgnoreCase) &&
|
|
||||||
!args[i].Contains("--waitForPid", StringComparison.InvariantCultureIgnoreCase))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
args[i] = string.Empty;
|
|
||||||
args[++i] = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
Process.Start(exe, $"--waitForPid {Environment.ProcessId} --tempAutostart true {string.Join(" ", args)}");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -65,7 +65,8 @@ internal static class AssemblyRewriter
|
|||||||
{
|
{
|
||||||
using var assembly = AssemblyDefinition.ReadAssembly(inputStream, new()
|
using var assembly = AssemblyDefinition.ReadAssembly(inputStream, new()
|
||||||
{
|
{
|
||||||
AssemblyResolver = resolver
|
AssemblyResolver = resolver,
|
||||||
|
ReadSymbols = true
|
||||||
});
|
});
|
||||||
foreach (var fieldDefinition in FindAllToRewrite(assembly.MainModule))
|
foreach (var fieldDefinition in FindAllToRewrite(assembly.MainModule))
|
||||||
{
|
{
|
||||||
|
@@ -293,15 +293,20 @@ namespace Torch
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _disposed = false;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void Destroy()
|
public virtual void Destroy()
|
||||||
{
|
{
|
||||||
|
if (_disposed) return;
|
||||||
Game.SignalDestroy();
|
Game.SignalDestroy();
|
||||||
if (!Game.WaitFor(VRageGame.GameState.Destroyed))
|
if (!Game.WaitFor(VRageGame.GameState.Destroyed))
|
||||||
Log.Warn("Failed to wait for the game to be destroyed");
|
Log.Warn("Failed to wait for the game to be destroyed");
|
||||||
Game = null;
|
Game = null;
|
||||||
|
|
||||||
Managers.Detach();
|
Managers.Detach();
|
||||||
|
|
||||||
|
_disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -325,7 +330,7 @@ namespace Torch
|
|||||||
if (MyAsyncSaving.InProgress || _inProgressSaves > 0)
|
if (MyAsyncSaving.InProgress || _inProgressSaves > 0)
|
||||||
{
|
{
|
||||||
Log.Error("Failed to save game, game is already saving");
|
Log.Error("Failed to save game, game is already saving");
|
||||||
return null;
|
return Task.FromResult(GameSaveResult.ConcurrentSaveInProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
global.json
Normal file
7
global.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"sdk": {
|
||||||
|
"version": "8.0.0",
|
||||||
|
"rollForward": "latestFeature",
|
||||||
|
"allowPrerelease": false
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user