mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-17 09:35:37 -05:00
Two changes in this PR: * Add a --log-dir command line parameter and fix command line parsing * Fix command line parsing where arguments with parameter were parsed incorrectly
59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
using System;
|
|
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
|
using Microsoft.SqlTools.ServiceLayer.Utility;
|
|
using Microsoft.SqlTools.Utility;
|
|
using System.IO;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer
|
|
{
|
|
/// <summary>
|
|
/// Main application class for SQL Tools API Service Host executable
|
|
/// </summary>
|
|
internal class Program
|
|
{
|
|
/// <summary>
|
|
/// Main entry point into the SQL Tools API Service Host
|
|
/// </summary>
|
|
internal static void Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
// read command-line arguments
|
|
CommandOptions commandOptions = new CommandOptions(args);
|
|
if (commandOptions.ShouldExit)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string logFilePath = "sqltools";
|
|
if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
|
|
{
|
|
logFilePath = Path.Combine(commandOptions.LoggingDirectory, logFilePath);
|
|
}
|
|
|
|
// turn on Verbose logging during early development
|
|
// we need to switch to Normal when preparing for public preview
|
|
Logger.Initialize(logFilePath: logFilePath, minimumLogLevel: LogLevel.Verbose, isEnabled: commandOptions.EnableLogging);
|
|
Logger.Write(LogLevel.Normal, "Starting SQL Tools Service Host");
|
|
|
|
// set up the host details and profile paths
|
|
var hostDetails = new HostDetails(version: new Version(1, 0));
|
|
|
|
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails);
|
|
ServiceHost serviceHost = HostLoader.CreateAndStartServiceHost(sqlToolsContext);
|
|
|
|
serviceHost.WaitForExit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.Write(LogLevel.Error, string.Format("An unhandled exception occurred: {0}", e));
|
|
Environment.Exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|