diff --git a/build/Version.props b/build/Version.props index 08a427b4de..3e78f78838 100644 --- a/build/Version.props +++ b/build/Version.props @@ -3,7 +3,7 @@ - 5.13.3 + 5.13.4 4.7.1 9.11.0 6.0.0 diff --git a/src/Tgstation.Server.Host.Service/Program.cs b/src/Tgstation.Server.Host.Service/Program.cs index 6073742252..79e589e7ff 100644 --- a/src/Tgstation.Server.Host.Service/Program.cs +++ b/src/Tgstation.Server.Host.Service/Program.cs @@ -86,64 +86,6 @@ namespace Tgstation.Server.Host.Service /// A resulting in the 's exit code. static Task Main(string[] args) => CommandLineApplication.ExecuteAsync(args); - /// - /// Runs sc.exe to either uninstall a given or install the running . - /// - /// The name of a service to uninstall. - static void InvokeSC(string serviceToUninstall) - { - using var installer = new ServiceInstaller(); - if (serviceToUninstall != null) - { - installer.Context = new InstallContext($"old-{serviceToUninstall}-uninstall.log", null); - installer.ServiceName = serviceToUninstall; - installer.Uninstall(null); - } - else - { - var fullPathToAssembly = Path.GetFullPath( - Assembly.GetExecutingAssembly().Location); - - var assemblyDirectory = Path.GetDirectoryName(fullPathToAssembly); - var assemblyNameWithoutExtension = Path.GetFileNameWithoutExtension(fullPathToAssembly); - var exePath = Path.Combine(assemblyDirectory, $"{assemblyNameWithoutExtension}.exe"); - - var programDataDirectory = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), - Server.Common.Constants.CanonicalPackageName); - - using var processInstaller = new ServiceProcessInstaller(); - processInstaller.Account = ServiceAccount.LocalSystem; - - // Mimicing Tgstation.Server.Host.Service.Wix here, which is the source of truth for this data - installer.Context = new InstallContext( - Path.Combine(programDataDirectory, $"tgs-install-{Guid.NewGuid()}.log"), - new[] - { - $"assemblypath=\"{exePath}\" -p=--appsettings-base-path={programDataDirectory}", - }); - installer.Description = $"{Server.Common.Constants.CanonicalPackageName} running as a Windows service."; - installer.DisplayName = Server.Common.Constants.CanonicalPackageName; - installer.StartType = ServiceStartMode.Automatic; - installer.ServicesDependedOn = new string[] { "Tcpip", "Dhcp", "Dnscache" }; - installer.ServiceName = ServerService.Name; - installer.Parent = processInstaller; - - var state = new ListDictionary(); - try - { - installer.Install(state); - - installer.Commit(state); - } - catch - { - installer.Rollback(state); - throw; - } - } - } - /// /// Command line handler, always runs. /// @@ -211,6 +153,63 @@ namespace Tgstation.Server.Host.Service } } + /// + /// Runs sc.exe to either uninstall a given or install the running . + /// + /// The name of a service to uninstall. + void InvokeSC(string serviceToUninstall) + { + using var installer = new ServiceInstaller(); + if (serviceToUninstall != null) + { + installer.Context = new InstallContext($"old-{serviceToUninstall}-uninstall.log", null); + installer.ServiceName = serviceToUninstall; + installer.Uninstall(null); + return; + } + + var fullPathToAssembly = Path.GetFullPath( + Assembly.GetExecutingAssembly().Location); + + var assemblyDirectory = Path.GetDirectoryName(fullPathToAssembly); + var assemblyNameWithoutExtension = Path.GetFileNameWithoutExtension(fullPathToAssembly); + var exePath = Path.Combine(assemblyDirectory, $"{assemblyNameWithoutExtension}.exe"); + + var programDataDirectory = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), + Server.Common.Constants.CanonicalPackageName); + + using var processInstaller = new ServiceProcessInstaller(); + processInstaller.Account = ServiceAccount.LocalSystem; + + // Mimicing Tgstation.Server.Host.Service.Wix here, which is the source of truth for this data + installer.Context = new InstallContext( + Path.Combine(programDataDirectory, $"tgs-install-{Guid.NewGuid()}.log"), + new[] + { + $"assemblypath=\"{exePath}\"{(String.IsNullOrWhiteSpace(PassthroughArgs) ? String.Empty : $" -p=\"{PassthroughArgs}\"")}", + }); + installer.Description = $"{Server.Common.Constants.CanonicalPackageName} running as a Windows service."; + installer.DisplayName = Server.Common.Constants.CanonicalPackageName; + installer.StartType = ServiceStartMode.Automatic; + installer.ServicesDependedOn = new string[] { "Tcpip", "Dhcp", "Dnscache" }; + installer.ServiceName = ServerService.Name; + installer.Parent = processInstaller; + + var state = new ListDictionary(); + try + { + installer.Install(state); + + installer.Commit(state); + } + catch + { + installer.Rollback(state); + throw; + } + } + /// /// Attempt to install the TGS Service. /// diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index 4c66a9136a..1b74ccfe08 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -202,12 +202,14 @@ namespace Tgstation.Server.Host.Components.StaticFiles { using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken)) { - await EnsureDirectories(cancellationToken); + var ensureDirectoriesTask = EnsureDirectories(cancellationToken); // just assume no other fs race conditions here var dmeExistsTask = ioManager.FileExists(ioManager.ConcatPath(CodeModificationsSubdirectory, dmeFile), cancellationToken); var headFileExistsTask = ioManager.FileExists(ioManager.ConcatPath(CodeModificationsSubdirectory, CodeModificationsHeadFile), cancellationToken); var tailFileExistsTask = ioManager.FileExists(ioManager.ConcatPath(CodeModificationsSubdirectory, CodeModificationsTailFile), cancellationToken); + + await ensureDirectoriesTask; var copyTask = ioManager.CopyDirectory( null, null,