mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-26 01:25:42 -05:00
* Initial changes to have serialization generate its own .exe * Removed additional project from sln file * remove all references to removed temporary project * Moved shared contracts into own dll and fixed imports. Addressed PR comments * Undid having a separate contracts project since that'll be a task for later on. Moved dbcellvalue and saveresultsrequest to Hosting, where they will be imported and shared by the service layer and serialization projects * Switched backslashes in project reference in csproj file to forward slashes for consistency * Moved necessary contracts back to service layer. Refactored CommandOptions to reduce code duplication. Addressed miscellaneous PR suggestions * Accidentally left these files out of previous commit * Initialized loggers for serialization and credentials with the logging directory provided by the cmd line arg, if there is one * Changed default log directory paths for serialization and credentials. Removed unnecessary cast and added a copyright * Changed name of generated executable for serialization service * removed unnecessary object cast * removing unnecessary imports and addressing other PR comments
64 lines
2.4 KiB
C#
64 lines
2.4 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 System.IO;
|
|
using Microsoft.SqlTools.Hosting.Utility;
|
|
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
|
using Microsoft.SqlTools.Utility;
|
|
|
|
namespace Microsoft.SqlTools.Serialization
|
|
{
|
|
/// <summary>
|
|
/// Main application class for Serialization Service Host executable
|
|
/// </summary>
|
|
internal class Program
|
|
{
|
|
private const string ServiceName = "SqlSerializationService.exe";
|
|
|
|
/// <summary>
|
|
/// Main entry point into the Serialization Service Host
|
|
/// </summary>
|
|
internal static void Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
// read command-line arguments
|
|
CommandOptions commandOptions = new CommandOptions(args, ServiceName);
|
|
if (commandOptions.ShouldExit)
|
|
{
|
|
return;
|
|
}
|
|
|
|
string logFilePath = "serialization";
|
|
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 SqlTools Serialization Provider");
|
|
|
|
// set up the host details and profile paths
|
|
var hostDetails = new HostDetails(
|
|
name: "SqlTools Serialization Provider",
|
|
profileId: "Microsoft.SqlTools.Serialization",
|
|
version: new Version(1, 0));
|
|
|
|
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails);
|
|
UtilityServiceHost serviceHost = HostLoader.CreateAndStartServiceHost(sqlToolsContext);
|
|
|
|
serviceHost.WaitForExit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.Write(LogLevel.Error, string.Format("An unhandled exception occurred: {0}", e));
|
|
Environment.Exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|