Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
aa7426dfa2 | ||
![]() |
7ea0a4f8b9 | ||
![]() |
d15985e918 | ||
![]() |
58340e0f5d | ||
![]() |
67bb3fd00c | ||
90546a78c2 |
37
.github/workflows/release.yaml
vendored
37
.github/workflows/release.yaml
vendored
@@ -5,7 +5,6 @@ on:
|
||||
branches: [master]
|
||||
|
||||
env:
|
||||
BUILD_CONFIGURATION: Release
|
||||
DOTNET_NOLOGO: true
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: true
|
||||
|
||||
@@ -33,36 +32,24 @@ jobs:
|
||||
name: Build and Publish Nuget
|
||||
runs-on: ubuntu-latest
|
||||
needs: [get-version]
|
||||
strategy:
|
||||
matrix:
|
||||
project: [ Torch.API, Torch, Torch.Server ]
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
name: Checkout
|
||||
|
||||
- uses: actions/setup-dotnet@v3
|
||||
- uses: actions/setup-dotnet@v4
|
||||
name: Setup dotnet
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- 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
|
||||
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 }}"
|
||||
- name: Pack
|
||||
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
|
||||
- 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 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
|
||||
- name: Push
|
||||
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
|
||||
|
||||
build:
|
||||
name: Build and Publish Package
|
||||
@@ -72,16 +59,14 @@ jobs:
|
||||
- uses: actions/checkout@master
|
||||
name: Checkout
|
||||
|
||||
- uses: actions/setup-dotnet@v3
|
||||
- uses: actions/setup-dotnet@v4
|
||||
name: Setup dotnet
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore Torch.Server/Torch.Server.csproj --locked-mode -r win-x64
|
||||
|
||||
- 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
|
||||
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
|
||||
|
||||
### Fork Difference
|
||||
* .NET 6.0 runtime
|
||||
* .NET 8.0 runtime
|
||||
* Optimized in-game scripts (also newer compiler & language versions)
|
||||
* 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
|
||||
@@ -19,7 +19,9 @@ Torch is the successor to SE Server Extender and gives server admins the tools t
|
||||
|
||||
### 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
|
||||
|
||||
@@ -30,7 +32,7 @@ If you have any questions or issues please join our [discord](https://discord.gg
|
||||
|
||||
# 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)
|
||||
|
||||
|
@@ -34,6 +34,7 @@ namespace Torch
|
||||
string LoginToken { get; set; }
|
||||
UpdateSource UpdateSource { get; set; }
|
||||
List<string> Packages { get; set; }
|
||||
int RestartSaveTimeout { get; set; }
|
||||
|
||||
void Save(string path = null);
|
||||
}
|
||||
|
@@ -33,6 +33,11 @@
|
||||
/// <summary>
|
||||
/// The save operation timed out
|
||||
/// </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);
|
||||
}
|
||||
}
|
@@ -114,14 +114,17 @@ public class TorchConfig : ViewModel, ITorchConfig
|
||||
|
||||
public UpdateSource UpdateSource { get; set; } = new()
|
||||
{
|
||||
Repository = "PveTeam/Torch",
|
||||
Url = "https://api.github.com",
|
||||
Repository = "PvE/Torch",
|
||||
Url = "https://git.zznty.ru/api/v1",
|
||||
SourceType = UpdateSourceType.Github
|
||||
};
|
||||
|
||||
[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);
|
||||
}
|
@@ -248,7 +248,8 @@ namespace Torch.Server
|
||||
{
|
||||
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))
|
||||
{
|
||||
Log.Error("Save failed due to {Reason}. Restart aborted!", saveResult);
|
||||
@@ -269,24 +270,7 @@ namespace Torch.Server
|
||||
)
|
||||
return;
|
||||
|
||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||
|
||||
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)}");
|
||||
ApplicationRestartHelper.RestartApplication();
|
||||
})
|
||||
{
|
||||
Name = "Restart thread"
|
||||
|
@@ -33,24 +33,7 @@ internal class UnhandledExceptionHandler
|
||||
Console.WriteLine("Restarting in 5 seconds.");
|
||||
Thread.Sleep(5000);
|
||||
|
||||
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||
|
||||
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)}");
|
||||
ApplicationRestartHelper.RestartApplication();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -330,7 +330,7 @@ namespace Torch
|
||||
if (MyAsyncSaving.InProgress || _inProgressSaves > 0)
|
||||
{
|
||||
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