mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 13:36:50 +01:00
Merge branch 'master' into DocUpdate
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
<!-- Integration tests will ensure they match across the board -->
|
||||
<Import Project="ControlPanelVersion.props" />
|
||||
<PropertyGroup>
|
||||
<TgsCoreVersion>5.13.3</TgsCoreVersion>
|
||||
<TgsCoreVersion>5.13.4</TgsCoreVersion>
|
||||
<TgsConfigVersion>4.7.1</TgsConfigVersion>
|
||||
<TgsApiVersion>9.11.0</TgsApiVersion>
|
||||
<TgsCommonLibraryVersion>6.0.0</TgsCommonLibraryVersion>
|
||||
|
||||
@@ -86,64 +86,6 @@ namespace Tgstation.Server.Host.Service
|
||||
/// <returns>A <see cref="Task"/> resulting in the <see cref="Program"/>'s exit code.</returns>
|
||||
static Task<int> Main(string[] args) => CommandLineApplication.ExecuteAsync<Program>(args);
|
||||
|
||||
/// <summary>
|
||||
/// Runs sc.exe to either uninstall a given <paramref name="serviceToUninstall"/> or install the running <see cref="ServerService"/>.
|
||||
/// </summary>
|
||||
/// <param name="serviceToUninstall">The name of a service to uninstall.</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command line handler, always runs.
|
||||
/// </summary>
|
||||
@@ -211,6 +153,63 @@ namespace Tgstation.Server.Host.Service
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs sc.exe to either uninstall a given <paramref name="serviceToUninstall"/> or install the running <see cref="ServerService"/>.
|
||||
/// </summary>
|
||||
/// <param name="serviceToUninstall">The name of a service to uninstall.</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to install the TGS Service.
|
||||
/// </summary>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user