Add functionality to shutdown Kusto process when parent process exits (#1609)

This commit is contained in:
Cory Rivera
2022-07-29 15:26:26 -07:00
committed by GitHub
parent 11dd29d8a0
commit 40df024dbc
7 changed files with 67 additions and 31 deletions

View File

@@ -22,7 +22,7 @@
<PropertyGroup Condition="'$(BUILD_DOTNET_TOOL)' == 'true'">
<PackageId>Microsoft.SqlServer.KustoServiceLayer.Tool</PackageId>
<PackageVersion>1.0.0</PackageVersion>
<PackageVersion>1.1.0</PackageVersion>
<PackageDescription>.NET client Kusto Service application, usable as a dotnet tool. This package is intended to be used by internal applications only and should not be referenced directly.</PackageDescription>
<PackAsTool>true</PackAsTool>
<ToolCommandName>$(AssemblyName)</ToolCommandName>

View File

@@ -48,6 +48,12 @@ namespace Microsoft.Kusto.ServiceLayer
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails);
ServiceHost serviceHost = HostLoader.CreateAndStartServiceHost(sqlToolsContext);
// If this service was started by another process, then it should shutdown when that parent process does.
if (commandOptions.ParentProcessId != null)
{
ProcessExitTimer.Start(commandOptions.ParentProcessId.Value);
}
serviceHost.WaitForExit();
}
catch (Exception e)