Compare commits

..

6 Commits

Author SHA1 Message Date
zznty
aa7426dfa2 push to new nuget
All checks were successful
Release / Get Version (push) Successful in 5s
Release / Build and Publish Nuget (Torch.API) (push) Successful in 2m0s
Release / Build and Publish Nuget (Torch) (push) Successful in 3m6s
Release / Build and Publish Nuget (Torch.Server) (push) Successful in 3m29s
Release / Build and Publish Package (push) Successful in 4m59s
2024-11-09 19:33:43 +07:00
zznty
7ea0a4f8b9 add optional restart save timeout 2024-11-09 19:28:27 +07:00
zznty
d15985e918 ensure restart save is exclusive to prevent save corruption 2024-11-09 19:06:10 +07:00
zznty
58340e0f5d fix reoccurring entry dll path in args when application restarts 2024-11-09 19:05:40 +07:00
zznty
67bb3fd00c update autoupdate default config
All checks were successful
Release / Get Version (push) Successful in 6s
Release / Build and Publish Package (push) Successful in 8m10s
Release / Build and Publish Nuget (push) Successful in 2m1s
2024-11-01 07:15:49 +07:00
90546a78c2 Update README.md
Some checks failed
Release / Build and Publish Nuget (push) Has been cancelled
Release / Build and Publish Package (push) Has been cancelled
Release / Get Version (push) Has been cancelled
2024-10-27 13:54:31 +00:00
10 changed files with 80 additions and 71 deletions

View File

@@ -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

View File

@@ -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://dcbadge.vercel.app/api/server/VAb2zgXHAN)](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)

View File

@@ -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);
} }

View File

@@ -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
} }
} }

View 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);
}
}

View File

@@ -114,13 +114,16 @@ 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);

View File

@@ -248,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);
@@ -269,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"

View File

@@ -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
{ {

View File

@@ -330,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
View File

@@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"rollForward": "latestFeature",
"allowPrerelease": false
}
}