mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 07:04:57 +01:00
Various cleanups very WIP
This commit is contained in:
@@ -19,6 +19,8 @@ artifacts:
|
||||
name: Server Console
|
||||
- path: artifacts/ServerService
|
||||
name: Server Service
|
||||
- path: artifacts/ServerHost
|
||||
name: Server Auto Update
|
||||
cache:
|
||||
- ~\.nuget\packages -> **\*.csproj
|
||||
- C:\ProgramData\chocolatey\bin -> appveyor.yml
|
||||
@@ -55,8 +57,10 @@ test_script:
|
||||
after_test:
|
||||
- ps: build/UploadCoverage.ps1
|
||||
- ps: build/BuildDox.ps1
|
||||
- dotnet publish src/Tgstation.Server.Host/Tgstation.Server.Host.csproj -o ../../artifacts/ServerHost -c %CONFIGURATION%
|
||||
- dotnet publish src/Tgstation.Server.Host.Console/Tgstation.Server.Host.Console.csproj -o ../../artifacts/ServerConsole -c %CONFIGURATION%
|
||||
- ps: Copy-Item -path "src/Tgstation.Server.Host.Service/bin/$env:CONFIGURATION" -destination artifacts/ServerService -recurse
|
||||
- ps: $env:TGSVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:APPVEYOR_BUILD_FOLDER/artifacts/ServerHost/Tgstation.Server.Host.dll").FileVersion
|
||||
deploy:
|
||||
- provider: GitHub
|
||||
release: "tgstation-server-v$(TGSVersion)"
|
||||
|
||||
@@ -3,6 +3,20 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<DebugType>Full</DebugType>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>Cyberboss</Authors>
|
||||
<Company>/tg/station</Company>
|
||||
<Description>API definitions for tgstation-server</Description>
|
||||
<PackageLicenseUrl>https://github.com/tgstation/tgstation-server/blob/master/LICENSE.md</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://tgstation.github.io/tgstation-server</PackageProjectUrl>
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/tgstation/tgstation-server/master/tgs.ico</PackageIconUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/tgstation/tgstation-server</RepositoryUrl>
|
||||
<Copyright>2018</Copyright>
|
||||
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
||||
<FileVersion>4.0.0.0</FileVersion>
|
||||
<PackageTags>json web api tgstation-server tgstation ss13 byond</PackageTags>
|
||||
<PackageReleaseNotes>Prototype release</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<DebugType>Full</DebugType>
|
||||
<Version>4.0.0.0</Version>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Authors>Cyberboss</Authors>
|
||||
<Company>/tg/station 13</Company>
|
||||
<Product />
|
||||
@@ -15,6 +15,8 @@
|
||||
<NeutralLanguage>en-CA</NeutralLanguage>
|
||||
<PackageIconUrl>https://raw.githubusercontent.com/tgstation/tgstation-server/master/build/tgs.ico</PackageIconUrl>
|
||||
<PackageLicenseUrl>https://github.com/tgstation/tgstation-server/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageTags>json web api tgstation-server tgstation ss13 byond client</PackageTags>
|
||||
<PackageReleaseNotes>Prototype release</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
||||
@@ -7,18 +7,18 @@ namespace Tgstation.Server.Host.Startup
|
||||
/// <summary>
|
||||
/// Represents the host
|
||||
/// </summary>
|
||||
public interface IServer
|
||||
public interface IServer : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The path to the updated assembly to run if any. Populated once <see cref="RunAsync(CancellationToken)"/> returns
|
||||
/// </summary>
|
||||
string UpdatePath { get; }
|
||||
Guid UpdateGuid { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Runs the <see cref="IServer"/>
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task RunAsync(CancellationToken cancellationToken);
|
||||
Task RunAsync(string updatesPath, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<DebugType>Full</DebugType>
|
||||
<AssemblyVersion>4.0.0.0</AssemblyVersion>
|
||||
<FileVersion>4.0.0.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
|
||||
@@ -57,6 +57,8 @@ namespace Tgstation.Server.Host.Watchdog
|
||||
logger.LogTrace("Determining location of host assembly...");
|
||||
var assemblyPath = serverFactory.GetType().Assembly.Location;
|
||||
logger.LogDebug("Path to initial host assembly: {0}", assemblyPath);
|
||||
|
||||
var firstIteration = true;
|
||||
do
|
||||
using (logger.BeginScope("Host invocation"))
|
||||
{
|
||||
@@ -69,11 +71,14 @@ namespace Tgstation.Server.Host.Watchdog
|
||||
break;
|
||||
|
||||
logger.LogInformation("Update path is set to \"{0}\", attempting host assembly hotswap...", server.UpdatePath);
|
||||
GC.Collect(Int32.MaxValue, GCCollectionMode.Forced, true, true);
|
||||
logger.LogTrace("Deleting old host assembly");
|
||||
activeAssemblyDeleter.DeleteActiveAssembly(assemblyPath);
|
||||
logger.LogTrace("Moving new host assembly in place...");
|
||||
File.Move(server.UpdatePath, assemblyPath);
|
||||
logger.LogTrace("Atttempting to create new server factory...");
|
||||
serverFactory = isolatedAssemblyLoader.CreateIsolatedServerFactory(assemblyPath);
|
||||
firstIteration = false;
|
||||
}
|
||||
while (!cancellationToken.IsCancellationRequested);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Models;
|
||||
|
||||
namespace Tgstation.Server.Host.Components
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Components
|
||||
this.repository = repository ?? throw new ArgumentNullException(nameof(repository));
|
||||
this.ioMananger = ioMananger ?? throw new ArgumentNullException(nameof(ioMananger));
|
||||
this.onDispose = onDispose ?? throw new ArgumentNullException(nameof(onDispose));
|
||||
IsGitHubRepository = Origin.ToUpperInvariant().Contains("GITHUB.COM");
|
||||
IsGitHubRepository = Origin.ToUpperInvariant().Contains("://GITHUB.COM/");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Host.Core;
|
||||
using Tgstation.Server.Host.IO;
|
||||
using Tgstation.Server.Host.Startup;
|
||||
|
||||
namespace Tgstation.Server.Host
|
||||
@@ -13,13 +14,23 @@ namespace Tgstation.Server.Host
|
||||
sealed class Server : IServer, IServerUpdater
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public string UpdatePath { get; private set; }
|
||||
public Guid? UpdateGuid { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IWebHostBuilder"/> for the <see cref="Server"/>
|
||||
/// </summary>
|
||||
readonly IWebHostBuilder webHostBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SemaphoreSlim"/> for the <see cref="Server"/>
|
||||
/// </summary>
|
||||
readonly SemaphoreSlim semaphore;
|
||||
|
||||
/// <summary>
|
||||
/// The absolute path to install updates to
|
||||
/// </summary>
|
||||
readonly string updatePath;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="cancellationTokenSource"/> for the <see cref="Server"/>
|
||||
/// </summary>
|
||||
@@ -29,7 +40,17 @@ namespace Tgstation.Server.Host
|
||||
/// Construct a <see cref="Server"/>
|
||||
/// </summary>
|
||||
/// <param name="webHostBuilder">The value of <see cref="webHostBuilder"/></param>
|
||||
public Server(IWebHostBuilder webHostBuilder) => this.webHostBuilder = webHostBuilder ?? throw new ArgumentNullException(nameof(webHostBuilder));
|
||||
/// <param name="updatePath">The value of <see cref="updatePath"/></param>
|
||||
public Server(IWebHostBuilder webHostBuilder, string updatePath)
|
||||
{
|
||||
this.webHostBuilder = webHostBuilder ?? throw new ArgumentNullException(nameof(webHostBuilder));
|
||||
this.updatePath = updatePath ?? throw new ArgumentNullException(nameof(updatePath));
|
||||
|
||||
semaphore = new SemaphoreSlim(1);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => semaphore.Dispose();
|
||||
|
||||
/// <inheritdoc />
|
||||
[ExcludeFromCodeCoverage]
|
||||
@@ -45,15 +66,24 @@ namespace Tgstation.Server.Host
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ApplyUpdate(string updatePath)
|
||||
public async Task ApplyUpdate(byte[] updateZipData, IIOManager ioManager, CancellationToken cancellationToken)
|
||||
{
|
||||
lock (this)
|
||||
using(await SemaphoreSlimContext.Lock(semaphore, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
if (updatePath != null)
|
||||
if (UpdateGuid != null)
|
||||
throw new InvalidOperationException("ApplyUpdate has already been called!");
|
||||
UpdatePath = updatePath;
|
||||
UpdateGuid = Guid.NewGuid();
|
||||
try
|
||||
{
|
||||
await ioManager.WriteAllBytes(serverUpdatePath, updateData, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
UpdateGuid = null;
|
||||
throw;
|
||||
}
|
||||
cancellationTokenSource.Cancel();
|
||||
}
|
||||
cancellationTokenSource.Cancel();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.11" />
|
||||
<PackageReference Include="Octokit" Version="0.31.0" />
|
||||
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.5.0" />
|
||||
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="4.5.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
|
||||
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.8.5" />
|
||||
|
||||
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
appveyor.yml = appveyor.yml
|
||||
LICENSE = LICENSE
|
||||
README.md = README.md
|
||||
v4_prototype_TODO.txt = v4_prototype_TODO.txt
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tgstation.Server.Host.Console", "src\Tgstation.Server.Host.Console\Tgstation.Server.Host.Console.csproj", "{A09C947F-4B9B-4AEE-AB50-47055EA05F18}"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Watchdog performance counters
|
||||
- Remember to catch PlatformNotSupportedException()
|
||||
|
||||
Event scripts
|
||||
|
||||
Repo synchronization
|
||||
|
||||
Repo controller
|
||||
|
||||
Install as network service instead of LocalSystem if win10 >= Creators update to allow for unprivileged symlinks
|
||||
|
||||
Nuspec stuff for api and client
|
||||
|
||||
Verify the byond cache folder location on linux
|
||||
|
||||
Map hosting address and certificate directly from configuration
|
||||
|
||||
Server updates. Use FOLDERS so dependencies can be properly packaged
|
||||
Reference in New Issue
Block a user