diff --git a/appveyor.yml b/appveyor.yml index 304cf440a7..dc70224a83 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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)" diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj index 3da598cb1b..1ccca2d0fb 100644 --- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj +++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj @@ -3,6 +3,20 @@ netstandard2.0 Full + true + Cyberboss + /tg/station + API definitions for tgstation-server + https://github.com/tgstation/tgstation-server/blob/master/LICENSE.md + https://tgstation.github.io/tgstation-server + https://raw.githubusercontent.com/tgstation/tgstation-server/master/tgs.ico + Git + https://github.com/tgstation/tgstation-server + 2018 + 4.0.0.0 + 4.0.0.0 + json web api tgstation-server tgstation ss13 byond + Prototype release diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj index ca8a985c9a..141da8fae0 100644 --- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj +++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj @@ -4,7 +4,7 @@ netstandard2.0 Full 4.0.0.0 - false + true Cyberboss /tg/station 13 @@ -15,6 +15,8 @@ en-CA https://raw.githubusercontent.com/tgstation/tgstation-server/master/build/tgs.ico https://github.com/tgstation/tgstation-server/blob/master/LICENSE + json web api tgstation-server tgstation ss13 byond client + Prototype release diff --git a/src/Tgstation.Server.Host.Startup/IServer.cs b/src/Tgstation.Server.Host.Startup/IServer.cs index 299e193036..1fd97d4930 100644 --- a/src/Tgstation.Server.Host.Startup/IServer.cs +++ b/src/Tgstation.Server.Host.Startup/IServer.cs @@ -7,18 +7,18 @@ namespace Tgstation.Server.Host.Startup /// /// Represents the host /// - public interface IServer + public interface IServer : IDisposable { /// /// The path to the updated assembly to run if any. Populated once returns /// - string UpdatePath { get; } + Guid UpdateGuid { get; } /// /// Runs the /// /// The for the operation /// A representing the running operation - Task RunAsync(CancellationToken cancellationToken); + Task RunAsync(string updatesPath, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj b/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj index e9797da445..13866885f6 100644 --- a/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj +++ b/src/Tgstation.Server.Host.Startup/Tgstation.Server.Host.Startup.csproj @@ -3,6 +3,8 @@ netstandard2.0 Full + 4.0.0.0 + 4.0.0.0 diff --git a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs index e4c3fc6a74..23f4a8968d 100644 --- a/src/Tgstation.Server.Host.Watchdog/Watchdog.cs +++ b/src/Tgstation.Server.Host.Watchdog/Watchdog.cs @@ -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); } diff --git a/src/Tgstation.Server.Host/Components/IRepository.cs b/src/Tgstation.Server.Host/Components/IRepository.cs index 09acbb72c5..08a500cb02 100644 --- a/src/Tgstation.Server.Host/Components/IRepository.cs +++ b/src/Tgstation.Server.Host/Components/IRepository.cs @@ -1,7 +1,6 @@ using System; using System.Threading; using System.Threading.Tasks; -using Tgstation.Server.Host.Models; namespace Tgstation.Server.Host.Components { diff --git a/src/Tgstation.Server.Host/Components/Repository.cs b/src/Tgstation.Server.Host/Components/Repository.cs index ed5f2676d3..218b21932c 100644 --- a/src/Tgstation.Server.Host/Components/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository.cs @@ -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/"); } /// diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs index ddf5ec2ece..5516c3287f 100644 --- a/src/Tgstation.Server.Host/Server.cs +++ b/src/Tgstation.Server.Host/Server.cs @@ -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 { /// - public string UpdatePath { get; private set; } + public Guid? UpdateGuid { get; private set; } /// /// The for the /// readonly IWebHostBuilder webHostBuilder; + /// + /// The for the + /// + readonly SemaphoreSlim semaphore; + + /// + /// The absolute path to install updates to + /// + readonly string updatePath; + /// /// The for the /// @@ -29,7 +40,17 @@ namespace Tgstation.Server.Host /// Construct a /// /// The value of - public Server(IWebHostBuilder webHostBuilder) => this.webHostBuilder = webHostBuilder ?? throw new ArgumentNullException(nameof(webHostBuilder)); + /// The value of + 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); + } + + /// + public void Dispose() => semaphore.Dispose(); /// [ExcludeFromCodeCoverage] @@ -45,15 +66,24 @@ namespace Tgstation.Server.Host } /// - 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(); } /// diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 662d012233..5b23cc7789 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -48,6 +48,7 @@ + diff --git a/tgstation-server.sln b/tgstation-server.sln index a123a25c5c..6b4c152ebc 100644 --- a/tgstation-server.sln +++ b/tgstation-server.sln @@ -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}" diff --git a/v4_prototype_TODO.txt b/v4_prototype_TODO.txt new file mode 100644 index 0000000000..f1e606e7b5 --- /dev/null +++ b/v4_prototype_TODO.txt @@ -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