Start service if configured during installation

This commit is contained in:
Jordan Dominion
2023-06-25 10:02:13 -04:00
parent e5858d02f4
commit 8614b07a9e
2 changed files with 29 additions and 18 deletions
@@ -4,7 +4,6 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using var process = new Process();
@@ -64,22 +63,31 @@ if (uninstall)
true);
}
if(shortcut && process.ExitCode == 0)
if ((shortcut || (interactive && !uninstall)) && process.ExitCode == 0)
{
Console.WriteLine();
Console.Write("tgstation-server is now configured. Would you like to (re)start the service? (Y/n): ");
var keyInfo = Console.ReadKey();
Console.WriteLine();
if (keyInfo.Key == ConsoleKey.Y || keyInfo.Key == ConsoleKey.Enter)
var startServer = interactive;
if (shortcut)
{
using (var stopService = new Process())
Console.WriteLine();
Console.Write("tgstation-server is now configured. Would you like to (re)start the service? (Y/n): ");
var keyInfo = Console.ReadKey();
Console.WriteLine();
if (keyInfo.Key == ConsoleKey.Y || keyInfo.Key == ConsoleKey.Enter)
{
stopService.StartInfo.FileName = "sc";
stopService.StartInfo.Arguments = "stop tgstation-server";
stopService.Start();
await stopService.WaitForExitAsync(CancellationToken.None); // DCT: None available
}
using (var stopService = new Process())
{
stopService.StartInfo.FileName = "sc";
stopService.StartInfo.Arguments = "stop tgstation-server";
stopService.Start();
await stopService.WaitForExitAsync(CancellationToken.None); // DCT: None available
}
startServer = true;
}
}
if (startServer)
{
using var startService = new Process();
startService.StartInfo.FileName = "sc";
startService.StartInfo.Arguments = "start tgstation-server";
@@ -87,9 +95,12 @@ if(shortcut && process.ExitCode == 0)
await startService.WaitForExitAsync(CancellationToken.None); // DCT: None available
}
Console.WriteLine("Press any key to exit this program...");
Console.ReadKey();
Console.WriteLine();
if (shortcut)
{
Console.WriteLine("Press any key to exit this program...");
Console.ReadKey();
Console.WriteLine();
}
}
// returning non-zero can make the installation uninstallable, no thanks
@@ -336,7 +336,7 @@
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:tgstation-server"
"ProductCode" = "8:{D24887FA-3228-4509-B5F3-4E07E349F278}"
"PackageCode" = "8:{F5E9572F-EBD8-43D4-AEF4-9EB8A70C7A0F}"
"PackageCode" = "8:{7B5CC9A0-D69D-41A1-956E-B9B3788ED3DC}"
"UpgradeCode" = "8:{151FE9F8-72CF-48D5-8E55-B7FB6BA9693E}"
"AspNetVersion" = "8:4.0.30319.0"
"RestartWWWService" = "11:FALSE"
@@ -814,7 +814,7 @@
"ContextData" = "8:"
"Attributes" = "3:0"
"Setting" = "3:2"
"Value" = "8:You can now start tgstation-server from your Services control panel. Press Win+R and enter 'services.msc' to access it. Then navigate to http://localhost:<API Port> to manage your server."
"Value" = "8:You can now navigate to http://localhost:<API Port> to manage your server."
"DefaultValue" = "8:#1258"
"UsePlugInResources" = "11:TRUE"
}